Nick Moore <n...@zoic.org> added the comment:

It's kind of funny that there's already consideration of this in 
_strptime._strptime(), which returns a tuple used by 
datetime.datetime.strptime() to construct the new datetime.
Search for `leap_year_fix`.

I think the concern though is if we changed the default year that might 
possibly break someone's existing code: thus my suggestion to allow the 
programmer to explicitly change the default.

However, I can also see that if their code is parsing dates in this way it is 
already wrong, and that if we're causing users pain now when they upgrade 
Python we're at least saving them pain at 2024-02-29 00:00:01.

Taking that approach, perhaps parsing dates with no year should just throw an 
exception, forcing the programmer to do it right the first time.  In this case 
though, I'd rather have a "year" kwarg to prevent the programmer having to do 
horrible string hacks like my code currently does.

I'm not sure: is it useful for me to produce a PR so we have something specific 
to consider?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26460>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to