jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/348444 )
Change subject: config2: use repr() of exceptions to prevent UnicodeDecodeErrors
......................................................................
config2: use repr() of exceptions to prevent UnicodeDecodeErrors
When no program is configured to open .py files, the
_win32_extension_command function will throw an OSError. On non-English
Windows versions, this error often contains non-ascii characters. On
Python 2, this error will be a str in the Windows' multi byte encoding.
Trying to decode this error with a different encoding will cause an
UnicodeDecodeError, which then blocks Pywikibot from being used.
Instead of trying to guess the correct encoding to use, use the repr()
of the string. This is guaranteed to be ascii, and can therefore always
be embedded in a unicode string safely.
Bug: T120222
Change-Id: I47e2756259ecbc1279e1124c076622177b3fc1d6
---
M pywikibot/config2.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 90877ba..e0bac1e 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -942,7 +942,7 @@
return cmd[:-1].strip()
except WindowsError as e:
# Catch any key lookup errors
- output('Unable to detect program for file extension "{0}":
{1}'.format(
+ output('Unable to detect program for file extension "{0}":
{1!r}'.format(
extension, e))
--
To view, visit
https://gerrit.wikimedia.org/r/348444
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I47e2756259ecbc1279e1124c076622177b3fc1d6
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>