mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
utils/web.py: Fix compatibility with Python 3.
This commit is contained in:
parent
cca1e6dba5
commit
774158f2ec
@ -117,8 +117,13 @@ def getUrlFd(url, headers=None, data=None):
|
||||
url = scheme + '://' + url
|
||||
request = urllib2.Request(url, headers=headers, data=data)
|
||||
if 'auth' in locals():
|
||||
if sys.version_info[0] >= 3 and isinstance(auth, str):
|
||||
auth = auth.encode()
|
||||
auth = base64.b64encode(auth)
|
||||
if sys.version_info[0] >= 3:
|
||||
auth = auth.decode()
|
||||
request.add_header('Authorization',
|
||||
'Basic ' + base64.b64encode(auth))
|
||||
'Basic ' + auth)
|
||||
else:
|
||||
request = url
|
||||
request.add_data(data)
|
||||
@ -212,3 +217,4 @@ def mungeEmail(s):
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user