[New-bugs-announce] [issue41702] Inconcistent behaviour in strftime

Valdemar Rolfsen report at bugs.python.org
Thu Sep 3 07:45:52 EDT 2020


New submission from Valdemar Rolfsen <valdemar.rolfsen at gmail.com>:

Inconsistency in strftime between python 3.6 and 3.7 when parsing first-century dates.

Python 3.6
>>> datetime.datetime.strptime(d, "%Y-%m-%d").strftime("%Y-%m-%d")
'0020-10-05'

Python 3.7
>>> datetime.datetime.strptime("0020-10-05", "%Y-%m-%d").strftime("%Y-%m-%d")
'20-10-05'

This means that the following would work for 3.6 but raise a ValueError for 3.7:

>>> d = "0020-10-05"
>>> d = datetime.datetime.strptime(d, "%Y-%m-%d").strftime("%Y-%m-%d")
>>> d = datetime.datetime.strptime(d, "%Y-%m-%d").strftime("%Y-%m-%d")

----------
components: Library (Lib)
messages: 376296
nosy: belopolsky, p-ganssle, valdemarrolfsen
priority: normal
severity: normal
status: open
title: Inconcistent behaviour in strftime
type: behavior
versions: Python 3.7

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


More information about the New-bugs-announce mailing list