jenkins-bot has submitted this change and it was merged.
Change subject: Make sure all variables passed to request are str ......................................................................
Make sure all variables passed to request are str
All parameters passed to request should be bytestrings - str. If any of them is accidentally unicode, this will try to convert all bytestrings to unicode via str.decode(sys.defaultencoding). This is problematic, because non-ascii data will then throw an UnicodeDecodeError as shown in [1].
[1] http://lists.wikimedia.org/pipermail/pywikipedia-l/2013-August/008218.html
Change-Id: I1b66a31c8752dee1f950d425d532479f1b671926 --- M wikipedia.py 1 file changed, 4 insertions(+), 4 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/wikipedia.py b/wikipedia.py index 976a310..4e3a543 100644 --- a/wikipedia.py +++ b/wikipedia.py @@ -6488,12 +6488,12 @@ address = address[:-1]
headers = { - 'User-agent': useragent, + 'User-agent': str(useragent), 'Content-Length': str(len(data)), - 'Content-type':contentType, + 'Content-type': str(contentType), } if cookies: - headers['Cookie'] = cookies + headers['Cookie'] = str(cookies)
if compress: headers['Accept-encoding'] = 'gzip' @@ -6507,7 +6507,7 @@ retry_attempt = 0 while True: try: - request = urllib2.Request(url, data, headers) + request = urllib2.Request(str(url), str(data), headers) f = MyURLopener.open(request)
# read & info can raise socket.error
pywikibot-commits@lists.wikimedia.org