mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Push code review advice from @sigmavirus24
This commit is contained in:
+5
-4
@@ -115,11 +115,12 @@ def get_netrc_auth(url, raise_errors=False):
|
||||
|
||||
ri = urlparse(url)
|
||||
|
||||
# Strip port numbers from netloc
|
||||
# Strip port numbers from netloc. This weird `if...encode`` dance is
|
||||
# used for Python 3.2, which doesn't support unicode literals.
|
||||
splitstr = b':'
|
||||
if isinstance(url, str):
|
||||
host = ri.netloc.split(u':')[0]
|
||||
else:
|
||||
host = ri.netloc.split(b':')[0]
|
||||
splitstr = splitstr.decode('ascii')
|
||||
host = ri.netloc.split(splitstr)[0]
|
||||
|
||||
try:
|
||||
_netrc = netrc(netrc_path).authenticators(host)
|
||||
|
||||
Reference in New Issue
Block a user