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 xtreak
Recipients belopolsky, eric.smith, matrixise, mjsaah, thatiparthy, xtreak
Date 2018-10-25.18:35:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Michael: I understand the inconsistency but since there is a test that says ValueError is  platform dependent then making it as an intentional error there might be breakage. I am not against changing this but if it's done then it should be done with DeprecationWarning for 3.8 and then later removed on other versions.

Some more information : 

Further, I looked into timemodule.c in CPython that says that it supports some common formats and "Other codes may be available on your platform.  See documentation for the C library strftime function." . I looked into freebsd strftime there is an explicit comment if conversion char is undefined then the behavior is also undefined and to just print it out. Related issue that has the patch to an external implementation that refers to the same comment : 

Meanwhile datetime strftime uses wrap_strftime that defines the custom error message when format ends with raw % and does some more error reporting.

# datetime strftime error :

# Freebsd
# Same comment on Apple's source :

case '%':
* X311J/88-090 ( if conversion char is
* undefined, behavior is undefined. Print out the
* character itself as printf(3) also does.

Initially I thought this is the relevant code that is printing the '%' but looking at the loop itself if the first character is "%" followed by '\0' indicating that it's just '%' then it breaks out of the loop and just returns '%' which I hope is happening on my system. I don't think the above case of printing out the character itself in the comment i.e. "%" is done here.

The above are based on my limited knowledge of C though so feel free to correct me if I am wrong on the above or took it out of context. So maybe this can be documented that for time.strftime the behavior is undefined when the conversion char is undefined and is based on the underlying operating system internals. Also a note that time.strftime with just '%' is system dependent meanwhile datetime.strftime '%' produces a ValueError. I think the same is noted in the test that this platform dependent depending on the implementation of strftime like in Windows. So if we are going to make '%' as an error from Python like datetime.strftime in time.strftime too then lies the breakage since Python behaves different from the underlying OS strftime implementation it uses for time module.

Hope it helps and maybe someone else with a better understanding of C has a better explanation.
Date User Action Args
2018-10-25 18:35:15xtreaksetrecipients: + xtreak, belopolsky, eric.smith, matrixise, thatiparthy, mjsaah
2018-10-25 18:35:15xtreaksetmessageid: <>
2018-10-25 18:35:15xtreaklinkissue35066 messages
2018-10-25 18:35:15xtreakcreate