jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Make the user-agent Python 3 compatible ......................................................................
[FIX] Make the user-agent Python 3 compatible
Python 3 break two things about user-agent: - 'encode' returns bytes and not a string, because the encoded result isn't used and it's only important that it could be encoded the result is discarded - The version of the git directory can't be determined, because the stdout (and stderr/stdin) are bytes (list of bytes) and not strings. Those need to be converted.
Change-Id: I191ab067eb2d8afe4e8f8d73f90408846add713a --- M pywikibot/comms/http.py M pywikibot/version.py 2 files changed, 7 insertions(+), 4 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py index 22a430d..e9703ff 100644 --- a/pywikibot/comms/http.py +++ b/pywikibot/comms/http.py @@ -143,7 +143,10 @@ return '' username = username.replace(' ', '_') # Avoid spaces or %20. try: - username = username.encode('ascii') + username.encode('ascii') # just test, but not actually use it + except UnicodeEncodeError: + pass + else: # % is legal in the default $wgLegalTitleChars # This is so that ops know the real pywikibot will not # allow a useragent in the username to allow through a hand-coded @@ -152,8 +155,6 @@ return quote(username) else: return username - except UnicodeEncodeError: - pass username = quote(username.encode('utf-8')) return username
diff --git a/pywikibot/version.py b/pywikibot/version.py index b58fa2f..2fd8cf9 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -16,6 +16,8 @@ import urllib import subprocess
+import pywikibot.config2 as config + cache = None
@@ -206,7 +208,7 @@ '--date=iso'], cwd=_program_dir, stdout=subprocess.PIPE).stdout.read() - info = info.split('|') + info = info.decode(config.console_encoding).split('|') date = info[0][:-6] date = time.strptime(date.strip('"'), '%Y-%m-%d %H:%M:%S') rev = subprocess.Popen([cmd, 'rev-list', 'HEAD'],
pywikibot-commits@lists.wikimedia.org