-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
GH-90750: Use datetime.fromisocalendar in _strptime #103802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It looks like this breaks both backwards compatibility and the documented behaviour of |
Maybe for some interpretations of backwards compatibility, but this doesn't break any existing tests and it seems like a bug that
That is the documented behavior of
This should be consistent with |
For fixing bugs that need a backwards compatibility break, we have the deprecation process. Here, given that week 0 is a documented extension to the ISO week numbers, rejecting
Yes, sorry. |
I'm sorry, can you clarify what you think this breaks? This PR does not affect the handling of week 0. This is the current behavior: >>> datetime.strptime("2019-01-1", "%G-%V-%u")
datetime.datetime(2018, 12, 31, 0, 0)
>>> datetime.strptime("2019-00-1", "%G-%V-%u")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
...
ValueError: time data '2019-00-1' does not match format '%G-%V-%u'
>>> datetime.strptime("2019-54-1", "%G-%V-%u")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
ValueError: time data '2019-54-1' does not match format '%G-%V-%u' What has changed is that I don't plan to backport this to 3.11, but I think that this can very reasonably be considered a bug fix. I think you may be thinking of |
This unifies the ISO → Gregorian conversion logic and improves handling of invalid ISO weeks.
cd62fb1
to
8aee83c
Compare
+1 for me on the fix itself. I think it can be considered a bugfix, but I also think it has a fair chance of breaking user code. Unless it's a lot of trouble, I'd probably keep the old logic with a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see now!
Sorry for the noise, and thanks for your patience explaining it.
No worries! I think I am going to skip the |
This unifies the ISO → Gregorian conversion logic and improves handling of invalid ISO weeks.