[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:

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:

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>

More information about the New-bugs-announce mailing list