[issue14157] time.strptime without a year fails on Feb 29

2016-02-29 Thread Sriram Rajagopalan

Sriram Rajagopalan added the comment:

Opened issue 26460 for fixing the leap day bug in datetime.datetime.strptime()

--

___
Python tracker 

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



[issue14157] time.strptime without a year fails on Feb 29

2016-02-29 Thread Sriram Rajagopalan

Sriram Rajagopalan added the comment:

datetime.strptime() uses the return value of _strptime() [ which returns 1900 
for 29th Feb without an year ] and eventually ends up calling 
datetime_new()->check_date_args() [ datetimemodule.c ] with 29th Feb 1900 and 
eventual failure.

Should we enhance check_date_args to take a year_dont_care flag and validate 
the input year argument only if it is explicitly passed?

--
nosy: +Sriram Rajagopalan

___
Python tracker 

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



[issue14157] time.strptime without a year fails on Feb 29

2016-02-29 Thread Andrej Antonov

Andrej Antonov added the comment:

$ python
Python 3.5.1 (default, Dec  7 2015, 12:58:09) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> 
>>> import time
>>> 
>>> time.strptime("Feb 29", "%b %d")
time.struct_time(tm_year=1900, tm_mon=2, tm_mday=29, tm_hour=0, tm_min=0, 
tm_sec=0, tm_wday=0, tm_yday=60, tm_isdst=-1)
>>> 
>>> 
>>> import datetime
>>> 
>>> datetime.datetime.strptime("Feb 29", "%b %d")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/_strptime.py", line 511, in _strptime_datetime
return cls(*args)
ValueError: day is out of range for month

--
nosy: +polymorphm

___
Python tracker 

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



[issue14157] time.strptime without a year fails on Feb 29

2013-10-23 Thread Phil Connell

Changes by Phil Connell pconn...@gmail.com:


--
nosy: +pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Martin Morrison

Martin Morrison martin.morri...@gmail.com added the comment:

This solution has some very undesirable properties - namely that Mar 1st is now 
less than Feb 29th!

It seems like the correct follow up fix would be to adjust the date of the 
returned struct_time back to 1900. The struct_time object doesn't have the 
validation issue, so this works fine. This pair of fixes then nicely 
circumvents the intermediate datetime object's checking, while providing a 
consistent end result.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

That's a good point, thank you. Hynek, do you want to provide a new patch?

--
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

On it.

I wonder whether it causes trouble that we return an invalid time_struct down 
the road?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

I have added a restoration including a short explanation + a regression test.

--
Added file: http://bugs.python.org/file25580/strptime-restore-1900.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

Small adjustments to the test as discussed in IRC.

--
assignee:  - hynek
resolution: fixed - 
stage: committed/rejected - patch review
type: enhancement - behavior
Added file: http://bugs.python.org/file25581/strptime-restore-1900-v2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 83598eb0d761 by Antoine Pitrou in branch '3.2':
Followup to issue #14157: respect the relative ordering of values produced by 
time.strptime().
http://hg.python.org/cpython/rev/83598eb0d761

New changeset d1c0b57aeb1b by Antoine Pitrou in branch 'default':
Followup to issue #14157: respect the relative ordering of values produced by 
time.strptime().
http://hg.python.org/cpython/rev/d1c0b57aeb1b

New changeset cbc9dc1c977e by Antoine Pitrou in branch '2.7':
Followup to issue #14157: respect the relative ordering of values produced by 
time.strptime().
http://hg.python.org/cpython/rev/cbc9dc1c977e

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-14 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Thanks, this should be fine now.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-10 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset f2ea7505c0d7 by Antoine Pitrou in branch '3.2':
Issue #14157: Fix time.strptime failing without a year on February 29th.
http://hg.python.org/cpython/rev/f2ea7505c0d7

New changeset a5a254e8a291 by Antoine Pitrou in branch 'default':
Issue #14157: Fix time.strptime failing without a year on February 29th.
http://hg.python.org/cpython/rev/a5a254e8a291

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-10 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 69d407b016c1 by Antoine Pitrou in branch '2.7':
Issue #14157: Fix time.strptime failing without a year on February 29th.
http://hg.python.org/cpython/rev/69d407b016c1

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-05-10 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Patch committed and pushed, thank you!

--
assignee: belopolsky - 
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-04-30 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-04-30 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

This is a bit of a hack, but seems to get the work done.  Does anyone have any 
objections to committing?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-04-30 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Fine with me.

--
nosy: +pitrou
stage: patch review - commit review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-04-29 Thread Hynek Schlawack

Changes by Hynek Schlawack h...@ox.cx:


--
keywords: +needs review
stage: needs patch - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-04-21 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

I gave it a shot, doesn’t look like a hack to me, what do you think?

--
keywords: +patch
Added file: http://bugs.python.org/file25301/strptime-on-leap-years.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-04-13 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

The point isn’t that time.strptime validates dates but that it uses datetime 
internally:

julian = datetime_date(year, month, day).toordinal() - \
  datetime_date(year, 1, 1).toordinal() + 1

Is it worth to reimplement this functionality?  It strikes easier to me to just 
use a different year if year is undefined and date == Feb 29.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-02-29 Thread Martin Morrison

New submission from Martin Morrison martin.morri...@gmail.com:

time.strptime without a year fails on Feb 29 with:

 time.strptime(Feb 29, %b %d)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.6/_strptime.py, line 454, in _strptime_time
return _strptime(data_string, format)[0]
  File /usr/lib/python2.6/_strptime.py, line 440, in _strptime
datetime_date(year, 1, 1).toordinal() + 1
ValueError: day is out of range for month

This is due to the use of 1900 as the default year when parsing. It would be 
nice to have an optional defaults keyword argument to the strptime function 
that can be used to override the defaults, thus allowing leap year dates to be 
parsed without specifying the date.

(Note: the code in question attempted to set the year *after* the parse so that 
ultimately there is a valid struct_time, but since the parse never succeeds, 
this can't work).

--
components: Library (Lib)
messages: 154621
nosy: Martin.Morrison
priority: normal
severity: normal
status: open
title: time.strptime without a year fails on Feb 29
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-02-29 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +belopolsky, haypo, hynek
versions: +Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-02-29 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

This strikes me as an implementation artifact.  There is no reason for 
time.strptime() to validate date triplets.  Applications that require valid 
dates can use datetime.strptime().  I suggest changing time.strptime() 
specification to match POSIX strptime().  My understanding is that POSIX only 
requires field by field range checking (%d range 01 to 31, %m range 01 to 12) 
and not full structure validation.  This would be consistent with the way leap 
seconds are currently treated:

 time.strptime('60', '%S')[5]
60

--
assignee:  - belopolsky
stage:  - needs patch
type: behavior - enhancement

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-02-29 Thread Shawn

Shawn swal...@opensolaris.org added the comment:

I'm seeing this when a year *is* specified with Python 2.6 and 2.7:


import time
time.strptime(20090229T184823Z, %Y%m%dT%H%M%SZ)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.6/_strptime.py, line 454, in _strptime_time
return _strptime(data_string, format)[0]
  File /usr/lib/python2.6/_strptime.py, line 440, in _strptime
datetime_date(year, 1, 1).toordinal() + 1
ValueError: day is out of range for month


import datetime
datetime.datetime.strptime(20090229T184823Z, %Y%m%dT%H%M%SZ)
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.6/_strptime.py, line 440, in _strptime
datetime_date(year, 1, 1).toordinal() + 1
ValueError: day is out of range for month

--
nosy: +swalker

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14157] time.strptime without a year fails on Feb 29

2012-02-29 Thread Shawn

Shawn swal...@opensolaris.org added the comment:

I'm an idiot; nevermind my comment.  The original date was bogus.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14157
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com