[New-bugs-announce] [issue35469] [2.7] time.asctime() regression

STINNER Victor report at bugs.python.org
Wed Dec 12 05:43:18 EST 2018


New submission from STINNER Victor <vstinner at redhat.com>:

It seems like bpo-31339 introduced a regression with commit eeadf5fc231163ec97a8010754d9c995c7c14876 to fix a security issue.

Copy of of bencordova's comment from GitHub:
https://github.com/python/cpython/pull/3293#issuecomment-446378058

I'm new at commenting on this project so apologies if this is not the appropriate place to do so.

>From what I can see (upgrading from python 2.7.13->2.7.15), the string format on line 648 of Modules/timemodule.c causes a different output from time.ctime() and time.asctime(t) for "days of the month < 10"

"%s %s%3d %.2d:%.2d:%.2d %d"

The "%3d" in this change removes the leading zero on the tm_mday but maintains a leading space.

Just looking for feedback on what the intention was and if this is a bug.

python 2.7.13:

>>> import time
>>> t = time.strptime("6 Dec 18", "%d %b %y")
>>> time.asctime(t)
'Thu Dec 06 00:00:00 2018'

python 2.7.15:

>>> import time
>>> t = time.strptime("6 Dec 18", "%d %b %y")
>>> time.asctime(t)
'Thu Dec  6 00:00:00 2018'

Note, the string with this change includes two spaces between "Dec" and "6" which also looks awkward.

Original Post:
https://github.com/python/cpython/commit/eeadf5fc231163ec97a8010754d9c995c7c14876#r31642310

----------
components: Library (Lib)
messages: 331687
nosy: vstinner
priority: normal
severity: normal
status: open
title: [2.7] time.asctime() regression
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35469>
_______________________________________


More information about the New-bugs-announce mailing list