test rebase
This commit is contained in:
@@ -11,9 +11,9 @@ an application may want to handle an exception like a regular
|
||||
response.
|
||||
"""
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
from ... import standard_library
|
||||
from future import standard_library
|
||||
|
||||
from . import response as urllib_response
|
||||
from future.backports.urllib import response as urllib_response
|
||||
|
||||
|
||||
__all__ = ['URLError', 'HTTPError', 'ContentTooShortError']
|
||||
|
||||
@@ -87,7 +87,7 @@ def clear_cache():
|
||||
# decoding and encoding. If valid use cases are
|
||||
# presented, we may relax this by using latin-1
|
||||
# decoding internally for 3.3
|
||||
_implicit_encoding = 'utf8'
|
||||
_implicit_encoding = 'ascii'
|
||||
_implicit_errors = 'strict'
|
||||
|
||||
def _noop(obj):
|
||||
@@ -122,7 +122,7 @@ class _ResultMixinStr(object):
|
||||
"""Standard approach to encoding parsed results from str to bytes"""
|
||||
__slots__ = ()
|
||||
|
||||
def encode(self, encoding='utf8', errors='strict'):
|
||||
def encode(self, encoding='ascii', errors='strict'):
|
||||
return self._encoded_counterpart(*(x.encode(encoding, errors) for x in self))
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class _ResultMixinBytes(object):
|
||||
"""Standard approach to decoding parsed results from bytes to str"""
|
||||
__slots__ = ()
|
||||
|
||||
def decode(self, encoding='utf8', errors='strict'):
|
||||
def decode(self, encoding='ascii', errors='strict'):
|
||||
return self._decoded_counterpart(*(x.decode(encoding, errors) for x in self))
|
||||
|
||||
|
||||
@@ -730,7 +730,7 @@ def quote_from_bytes(bs, safe='/'):
|
||||
###
|
||||
if isinstance(safe, str):
|
||||
# Normalize 'safe' by converting to bytes and removing non-ASCII chars
|
||||
safe = str(safe).encode('utf8', 'ignore')
|
||||
safe = str(safe).encode('ascii', 'ignore')
|
||||
else:
|
||||
### For Python-Future:
|
||||
safe = bytes(safe)
|
||||
|
||||
@@ -827,7 +827,7 @@ class ProxyHandler(BaseHandler):
|
||||
if user and password:
|
||||
user_pass = '%s:%s' % (unquote(user),
|
||||
unquote(password))
|
||||
creds = base64.b64encode(user_pass.encode()).decode("utf8")
|
||||
creds = base64.b64encode(user_pass.encode()).decode("ascii")
|
||||
req.add_header('Proxy-authorization', 'Basic ' + creds)
|
||||
hostport = unquote(hostport)
|
||||
req.set_proxy(hostport, proxy_type)
|
||||
@@ -977,7 +977,7 @@ class AbstractBasicAuthHandler(object):
|
||||
user, pw = self.passwd.find_user_password(realm, host)
|
||||
if pw is not None:
|
||||
raw = "%s:%s" % (user, pw)
|
||||
auth = "Basic " + base64.b64encode(raw.encode()).decode("utf8")
|
||||
auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii")
|
||||
if req.headers.get(self.auth_header, None) == auth:
|
||||
return None
|
||||
req.add_unredirected_header(self.auth_header, auth)
|
||||
@@ -1080,7 +1080,7 @@ class AbstractDigestAuthHandler(object):
|
||||
# authentication, and to provide some message integrity protection.
|
||||
# This isn't a fabulous effort, but it's probably Good Enough.
|
||||
s = "%s:%s:%s:" % (self.nonce_count, nonce, time.ctime())
|
||||
b = s.encode("utf8") + _randombytes(8)
|
||||
b = s.encode("ascii") + _randombytes(8)
|
||||
dig = hashlib.sha1(b).hexdigest()
|
||||
return dig[:16]
|
||||
|
||||
@@ -1147,9 +1147,9 @@ class AbstractDigestAuthHandler(object):
|
||||
def get_algorithm_impls(self, algorithm):
|
||||
# lambdas assume digest modules are imported at the top level
|
||||
if algorithm == 'MD5':
|
||||
H = lambda x: hashlib.md5(x.encode("utf8")).hexdigest()
|
||||
H = lambda x: hashlib.md5(x.encode("ascii")).hexdigest()
|
||||
elif algorithm == 'SHA':
|
||||
H = lambda x: hashlib.sha1(x.encode("utf8")).hexdigest()
|
||||
H = lambda x: hashlib.sha1(x.encode("ascii")).hexdigest()
|
||||
# XXX MD5-sess
|
||||
KD = lambda s, d: H("%s:%s" % (s, d))
|
||||
return H, KD
|
||||
@@ -1829,13 +1829,13 @@ class URLopener(object):
|
||||
|
||||
if proxy_passwd:
|
||||
proxy_passwd = unquote(proxy_passwd)
|
||||
proxy_auth = base64.b64encode(proxy_passwd.encode()).decode('utf8')
|
||||
proxy_auth = base64.b64encode(proxy_passwd.encode()).decode('ascii')
|
||||
else:
|
||||
proxy_auth = None
|
||||
|
||||
if user_passwd:
|
||||
user_passwd = unquote(user_passwd)
|
||||
auth = base64.b64encode(user_passwd.encode()).decode('utf8')
|
||||
auth = base64.b64encode(user_passwd.encode()).decode('ascii')
|
||||
else:
|
||||
auth = None
|
||||
http_conn = connection_factory(host)
|
||||
@@ -2040,7 +2040,7 @@ class URLopener(object):
|
||||
msg.append('Content-type: %s' % type)
|
||||
if encoding == 'base64':
|
||||
# XXX is this encoding/decoding ok?
|
||||
data = base64.decodebytes(data.encode('utf8')).decode('latin-1')
|
||||
data = base64.decodebytes(data.encode('ascii')).decode('latin-1')
|
||||
else:
|
||||
data = unquote(data)
|
||||
msg.append('Content-Length: %d' % len(data))
|
||||
@@ -2498,17 +2498,7 @@ def _proxy_bypass_macosx_sysconf(host, proxy_settings):
|
||||
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
try:
|
||||
from _scproxy import _get_proxy_settings, _get_proxies
|
||||
except:
|
||||
try:
|
||||
# By default use environment variables
|
||||
_get_proxy_settings = getproxies_environment
|
||||
_get_proxies = proxy_bypass_environment
|
||||
getproxies = getproxies_environment
|
||||
proxy_bypass = proxy_bypass_environment
|
||||
except:
|
||||
pass
|
||||
from _scproxy import _get_proxy_settings, _get_proxies
|
||||
|
||||
def proxy_bypass_macosx_sysconf(host):
|
||||
proxy_settings = _get_proxy_settings()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import absolute_import, division, unicode_literals
|
||||
from ...builtins import str
|
||||
from future.builtins import str
|
||||
""" robotparser.py
|
||||
|
||||
Copyright (C) 2000 Bastian Kleineidam
|
||||
@@ -13,8 +13,8 @@ from ...builtins import str
|
||||
"""
|
||||
|
||||
# Was: import urllib.parse, urllib.request
|
||||
from .. import urllib
|
||||
from . import parse as _parse, request as _request
|
||||
from future.backports import urllib
|
||||
from future.backports.urllib import parse as _parse, request as _request
|
||||
urllib.parse = _parse
|
||||
urllib.request = _request
|
||||
|
||||
|
||||
Reference in New Issue
Block a user