Skip to content

bpo-45386: Handle strftime's ValueError graciously#28765

Merged
ambv merged 1 commit into
python:mainfrom
rtobar:fix-issue-45386
Oct 13, 2021
Merged

bpo-45386: Handle strftime's ValueError graciously#28765
ambv merged 1 commit into
python:mainfrom
rtobar:fix-issue-45386

Conversation

@rtobar
Copy link
Copy Markdown
Contributor

@rtobar rtobar commented Oct 6, 2021

At import time, the xmlrpc.client module uses different date formats to
test strftime so it can format years with 4 digits consistently.
Depending on the underlying C library and its strftime implementation
some of these calls can result in ValueErrors, blocking the
xmlrpc.client module from being imported.

This commit changes the behavior of this bit of code to react to
ValueError exceptions, treating the format that caused them as an
non-viable option.

https://bugs.python.org/issue45386

At import time, the xmlrpc.client module uses different date formats to
test strftime so it can format years with 4 digits consistently.
Depending on the underlying C library and its strftime implementation
some of these calls can result in ValueErrors, blocking the
xmlrpc.client module from being imported.

This commit changes the behavior of this bit of code to react to
ValueError exceptions, treating the format that caused them as an
non-viable option.
Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ambv ambv merged commit 1c83135 into python:main Oct 13, 2021
@miss-islington
Copy link
Copy Markdown
Contributor

Thanks @rtobar for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 13, 2021
…ythonGH-28765)

At import time, the xmlrpc.client module uses different date formats to
test strftime so it can format years with 4 digits consistently.
Depending on the underlying C library and its strftime implementation
some of these calls can result in ValueErrors, blocking the
xmlrpc.client module from being imported.

This commit changes the behavior of this bit of code to react to
ValueError exceptions, treating the format that caused them as an
non-viable option.
(cherry picked from commit 1c83135)

Co-authored-by: rtobar <rtobarc@gmail.com>
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Oct 13, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 13, 2021
…ythonGH-28765)

At import time, the xmlrpc.client module uses different date formats to
test strftime so it can format years with 4 digits consistently.
Depending on the underlying C library and its strftime implementation
some of these calls can result in ValueErrors, blocking the
xmlrpc.client module from being imported.

This commit changes the behavior of this bit of code to react to
ValueError exceptions, treating the format that caused them as an
non-viable option.
(cherry picked from commit 1c83135)

Co-authored-by: rtobar <rtobarc@gmail.com>
@bedevere-bot
Copy link
Copy Markdown

GH-28934 is a backport of this pull request to the 3.10 branch.

@bedevere-bot
Copy link
Copy Markdown

GH-28935 is a backport of this pull request to the 3.9 branch.

ambv pushed a commit that referenced this pull request Oct 13, 2021
…H-28765) (GH-28934)

At import time, the xmlrpc.client module uses different date formats to
test strftime so it can format years with 4 digits consistently.
Depending on the underlying C library and its strftime implementation
some of these calls can result in ValueErrors, blocking the
xmlrpc.client module from being imported.

This commit changes the behavior of this bit of code to react to
ValueError exceptions, treating the format that caused them as an
non-viable option.
(cherry picked from commit 1c83135)

Co-authored-by: rtobar <rtobarc@gmail.com>
ambv pushed a commit that referenced this pull request Oct 13, 2021
…H-28765) (GH-28935)

At import time, the xmlrpc.client module uses different date formats to
test strftime so it can format years with 4 digits consistently.
Depending on the underlying C library and its strftime implementation
some of these calls can result in ValueErrors, blocking the
xmlrpc.client module from being imported.

This commit changes the behavior of this bit of code to react to
ValueError exceptions, treating the format that caused them as an
non-viable option.
(cherry picked from commit 1c83135)

Co-authored-by: rtobar <rtobarc@gmail.com>
@rtobar rtobar deleted the fix-issue-45386 branch October 13, 2021 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants