[issue5979] strptime() gives inconsistent exceptions

Alexander Belopolsky report at bugs.python.org
Sun Jun 6 04:07:45 CEST 2010


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Looks like a bug to me:

>>> datetime.strptime("1", "%d")
datetime.datetime(1900, 1, 1, 0, 0)

>>> datetime.strptime('1', '%m')
datetime.datetime(1900, 1, 1, 0, 0)

both %m and %d accept single digits but they should not.

>>> datetime.strptime('123', '%m%d')
datetime.datetime(1900, 12, 3, 0, 0)

>>> import this
..
In the face of ambiguity, refuse the temptation to guess.

----------
assignee:  -> belopolsky
nosy: +belopolsky
stage:  -> unit test needed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5979>
_______________________________________


More information about the Python-bugs-list mailing list