classification
Title: xmlrpc.client unimportable due to strfmt ValueError
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lukasz.langa, miss-islington, rtobar, rtobar2
Priority: normal Keywords: patch

Created on 2021-10-06 06:53 by rtobar2, last changed 2021-10-13 18:00 by lukasz.langa. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 28765 merged rtobar, 2021-10-06 16:06
PR 28934 merged miss-islington, 2021-10-13 16:38
PR 28935 merged miss-islington, 2021-10-13 16:38
Messages (5)
msg403288 - (view) Author: Rodrigo Tobar (rtobar2) * Date: 2021-10-06 06:53
This is a problem caused by https://bugs.python.org/issue13305.

When running python in SerenityOS (https://serenityos.org/), the xmlrpc.client module fails to be imported. This is because the code that decides which format to use for getting 4-digit years, which issues a call to strfmt, raises a ValueError. The ValueError is raised because the second format that is tested yields no output with Serenity's strfmt implementation, so timemodule.strfmt returns NULL.

For reference, this is the code that fails:


_day0 = datetime(1, 1, 1)
if _day0.strftime('%Y') == '0001':      # Mac OS X
    def _iso8601_format(value):
        return value.strftime("%Y%m%dT%H:%M:%S")
elif _day0.strftime('%4Y') == '0001':   # Linux   <-- ValueError
    def _iso8601_format(value):
        return value.strftime("%4Y%m%dT%H:%M:%S")
else:
    def _iso8601_format(value):
        return value.strftime("%Y%m%dT%H:%M:%S").zfill(17)
del _day0

We have a local patch that improves on the current code, which I'll post as a PR now.
msg403850 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-10-13 16:38
New changeset 1c831353816ff699b54e804047a7242a09e98f5b by rtobar in branch 'main':
bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765)
https://github.com/python/cpython/commit/1c831353816ff699b54e804047a7242a09e98f5b
msg403865 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-10-13 17:59
New changeset f40b230df91f29fa4a84c1d127b4eab56a6eda27 by Miss Islington (bot) in branch '3.10':
bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765) (GH-28934)
https://github.com/python/cpython/commit/f40b230df91f29fa4a84c1d127b4eab56a6eda27
msg403866 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-10-13 18:00
New changeset 9210eff61b75edabbe9263df0c4a303fc2149a22 by Miss Islington (bot) in branch '3.9':
bpo-45386: Handle strftime's ValueError graciously in xmlrpc.client (GH-28765) (GH-28935)
https://github.com/python/cpython/commit/9210eff61b75edabbe9263df0c4a303fc2149a22
msg403867 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-10-13 18:00
Thanks, R! ✨ 🍰 ✨
History
Date User Action Args
2021-10-13 18:00:49lukasz.langasetstatus: open -> closed
versions: + Python 3.9, Python 3.11
type: behavior
messages: + msg403867

resolution: fixed
stage: patch review -> resolved
2021-10-13 18:00:10lukasz.langasetmessages: + msg403866
2021-10-13 17:59:53lukasz.langasetmessages: + msg403865
2021-10-13 16:38:48miss-islingtonsetpull_requests: + pull_request27223
2021-10-13 16:38:44miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request27222
2021-10-13 16:38:40lukasz.langasetnosy: + lukasz.langa
messages: + msg403850
2021-10-06 16:06:45rtobarsetkeywords: + patch
nosy: + rtobar

pull_requests: + pull_request27105
stage: patch review
2021-10-06 06:53:26rtobar2create