-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
datetime.strptime
no longer raises ValueError: stray % in format '%Y %'
#131434
Comments
@picnixz This is in The error does not execute, I will look into this. Lines 448 to 449 in b8367e7
I presume it was because of this commit, 5f4e5b5 I will revert it and see if it fixes it. Edit: I was correct, it was Serhiys commit. It will not be as simple as I though to fix as we no longer iterate over the format. @serhiy-storchaka any ideas for a fix for your old commit? |
…time() In particularly, fix regression in detecting stray % at the end of the format string.
Good catch! Indeed, the regression was introduced in #125406. There was only one test that indirectly tested this error, but it was broken, so the regression has not been noticed. #131568 fixes the regression for stray % at the end of the format string, and also improves error reporting for some other cases. |
…time() In particularly, fix regression in detecting stray % at the end of the format string.
…n error Treat trailing % at the end of a format string consistently with % followed by spaces inside a format string. The IndexError which was previously raised when there was a trailing % can no longer happen, so we can remove the dead code dealing with it. Note the ValueError's message in this case has changed from "stray % in format '...'" to "'%' is a bad directive in format '...'". We could treat this as a special case and retain the previous wording if desired, but ISTM that consistency is better than strict backwards compatibility here.
Sorry, I was looking at this and didn't refresh the page and notice you already had a fix :-) |
Bug report
Bug description:
in 3.13.2 and 3.13.1
datetime.strptime
no longer raisesValueError: stray % in format '%Y %'
as it used to do in 3.13.0:
and e.g. 3.10:
edit 1:
got the same in the latest 3.12.9 (used to work in older 3.12)
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
The text was updated successfully, but these errors were encountered: