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 mjsaah
Recipients belopolsky, eric.smith, matrixise, mjsaah, p-ganssle, pablogsal, terry.reedy, thatiparthy, xtreak
Date 2018-11-23.22:30:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAAGJmtTJSDm02qi11rFNemSK-SpAYDBDqJsrL+m7HWLp56uHDA@mail.gmail.com>
In-reply-to <1540580876.27.0.788709270274.issue35066@psf.upfronthosting.co.za>
Content
Summary to accompany my patch:

Modules/_datetimemodule.c and Lib/datetime.py do not behave identically.
Specifically, the strftime functions do not match when passed a format
string
terminated with a '%'. The C function performs an explicit check for this
condition, and raises a ValueError on it. The Py version does not perform
this check. Both pass the
format string (after doing substitutions for %z, %Z, and %f tags) to the
system strftime or wcfstime, depending on platform. These live within the
python time module. The
time module wrapper function does not perform this check.

This situation leads to a scenario in which, for example, "%D %" passed to
datetime.strftime (with the C extension included) raises a value error. The
same string passed to
time.strftime returns "mm/dd/yy %", at least on OSX. Furthermore, if Python
is built without the C module, "mm/dd/yy %" is returned when
datetime.strftime is called.

To summarise, there are two problems: (1) datetime does not comply with
PEP-399, and (2) a higher-order module raises an exception on a case that
the (exposed) lower-order
module has no problem with, causing a mismatch in behavior between
datetime.strftime and time.strftime.

This PR attempts to fix this problem by removing the case check from the
datetime C module. This solves both (1) and (2).

There was much talk on the issue thread about there existing a test case
for time.strftime that documented a platform-dependent failure on a
dangling '%'. I wish to note
that my patch does not touch the time module at all, it only removes a
seemingly unnecessary check in the datetime C module.
History
Date User Action Args
2018-11-23 22:30:11mjsaahsetrecipients: + mjsaah, terry.reedy, belopolsky, eric.smith, matrixise, thatiparthy, p-ganssle, pablogsal, xtreak
2018-11-23 22:30:11mjsaahlinkissue35066 messages
2018-11-23 22:30:11mjsaahcreate