jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1026185?usp=email )
Change subject: version.py: Remove line endings in getversion_nightly ......................................................................
version.py: Remove line endings in getversion_nightly
The version strings are eventually passed into the user agent, and having a linebreak results in a user agent such as:
script (wikipedia:test; User:Bot) Pywikibot/9.2.0.dev1 (1\n) requests/2.28.2 Python/3.9.2.final.0
This \n causes the result to fail with error:
pywikibot.exceptions.FatalServerError: Invalid leading whitespace, reserved character(s), or returncharacter(s) in header value.
Fix this by, instead of using readlines, which preserves the line endings, read the entire file and split by linebreak, which implicitly removes all the line endings.
Bug: T363943 Change-Id: I38f9b27d3339916dc6b784ecda602055924aa6bc --- M pywikibot/version.py 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/version.py b/pywikibot/version.py index 542c480..40793a0 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -259,7 +259,7 @@ file = Path(path or _get_program_dir()) / 'pywikibot' / 'version'
with file.open() as data: - (tag, rev, date, hsh) = data.readlines() + (tag, rev, date, hsh) = data.read().splitlines()
date = time.strptime(date[:19], '%Y-%m-%dT%H:%M:%S')