Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

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

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Apr 13, 2012, 5:46 AM

Post #1 of 16 (93 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29

Hynek Schlawack <hs [at] ox> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 21, 2012, 10:09 AM

Post #2 of 16 (86 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Hynek Schlawack <hs [at] ox> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 8:41 AM

Post #3 of 16 (74 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Changes by Hynek Schlawack <hs [at] ox>:


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

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 30, 2012, 6:29 AM

Post #4 of 16 (74 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Changes by Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA [at] GMail>:


----------
nosy: +Arfrever

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 30, 2012, 6:40 AM

Post #5 of 16 (74 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Alexander Belopolsky <alexander.belopolsky [at] gmail> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 30, 2012, 4:06 PM

Post #6 of 16 (74 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

Fine with me.

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

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 10, 2012, 11:20 AM

Post #7 of 16 (69 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Roundup Robot <devnull [at] psf> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 10, 2012, 11:23 AM

Post #8 of 16 (65 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Roundup Robot <devnull [at] psf> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 10, 2012, 11:24 AM

Post #9 of 16 (65 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

Patch committed and pushed, thank you!

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

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 14, 2012, 9:50 AM

Post #10 of 16 (63 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Martin Morrison <martin.morrison [at] gmail> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 14, 2012, 9:54 AM

Post #11 of 16 (63 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

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

----------
status: closed -> open

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 14, 2012, 10:00 AM

Post #12 of 16 (62 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Hynek Schlawack <hs [at] ox> added the comment:

On it.

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

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 14, 2012, 10:28 AM

Post #13 of 16 (66 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Hynek Schlawack <hs [at] ox> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 14, 2012, 10:35 AM

Post #14 of 16 (66 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Hynek Schlawack <hs [at] ox> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 14, 2012, 10:50 AM

Post #15 of 16 (64 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Roundup Robot <devnull [at] psf> 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 <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 14, 2012, 10:51 AM

Post #16 of 16 (63 views)
Permalink
[issue14157] time.strptime without a year fails on Feb 29 [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

Thanks, this should be fine now.

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

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14157>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.