This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author michael-o
Recipients michael-o
Date 2018-08-14.13:36:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1534253809.16.0.56676864532.issue34404@psf.upfronthosting.co.za>
In-reply-to
Content
I see a test failure on HP-UX:
> test_negative (test.test_time.TestStrftime4dyear) ... FAIL
> ======================================================================
> FAIL: test_negative (test.test_time.TestStrftime4dyear)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/var/osipovmi/cpython/Lib/test/test_time.py", line 687, in test_negative
>     return super().test_negative()
>   File "/var/osipovmi/cpython/Lib/test/test_time.py", line 713, in test_negative
>     self.assertEqual(self.yearstr(-1), self._format % -1)
> AssertionError: '-0001' != '-001'
> - -0001
> ?  -
> + -001

The bug is in the test class, not cause by HP-UX.
Lib/test/test_time.py:713 says "self.assertEqual(self.yearstr(-1), self._format % -1)" where self._format is set in line 654 to "_format = '%04d'" because
> Python 3.7.0+ (heads/3.7-dirty:ea8835fb30, Aug 14 2018, 14:44:19) [C] on hp-ux11
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import time
> >>> time.strftime('%Y', (1,) + (0,) * 8)
> '0001'

Unfortunately, the zero padding in printf() applies to the entire string length. So
> >>> "%+04d" % -1
> '-001'

on HP-UX, Linux and FreeBSD.

The format string must add an additional zero for negative numbers.
History
Date User Action Args
2018-08-14 13:36:49michael-osetrecipients: + michael-o
2018-08-14 13:36:49michael-osetmessageid: <1534253809.16.0.56676864532.issue34404@psf.upfronthosting.co.za>
2018-08-14 13:36:49michael-olinkissue34404 messages
2018-08-14 13:36:49michael-ocreate