[issue19376] document that strptime() does not support the Feb 29 if the format does not contain the year

2013-10-24 Thread Matthew Earl

Matthew Earl added the comment:

Out of interest, what's the reason for accepting the time.strptime() version as 
a bug, but not datetime.datetime.strptime()? Is it that time.strptime() is 
meant to be a simple parsing from string to tuple (with minimal checks), 
whereas datetime.datetime.strptime() should represent an actual point in time, 
therefore extra validation is expected to occur?

If so I'm happy to either close or add a small note to the docs (I don't mind 
which.)

--

___
Python tracker 
<http://bugs.python.org/issue19376>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19376] datetime.datetime.strptime without a year fails on Feb 29

2013-10-24 Thread Matthew Earl

New submission from Matthew Earl:

datetime.datetime.strptime() without a year fails on Feb 29 with:

>>> datetime.datetime.strptime("Feb 29", "%b %d")
Traceback (most recent call last):
  File "", line 1, in 
  File "/auto/ensoft-sjc/thirdparty/lib/python3.3/_strptime.py", line 511, in 
_strptime_datetime
return cls(*args)
ValueError: day is out of range for month

This is because without a year specified the year is assumed to be 1900, which 
is not a leap year. The underlying _strptime._strptime() function has some 
munging such that it doesn't itself fail (see #14157):

>>> _strptime._strptime("Feb 29", "%b %d")
((1900, 2, 29, 0, 0, 0, 0, 60, -1, None, None), 0)

...however datetime.datetime.__init__() is called with this tuple as *args, 
causing the validation failure.

--
components: Library (Lib)
messages: 201108
nosy: Arfrever, Martin.Morrison, Matthew.Earl, belopolsky, haypo, hynek, 
pconnell, pitrou, swalker
priority: normal
severity: normal
status: open
title: datetime.datetime.strptime without a year fails on Feb 29
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

___
Python tracker 
<http://bugs.python.org/issue19376>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com