diff --git a/requests/utils.py b/requests/utils.py index 132cd2b5..563248fb 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -116,7 +116,10 @@ def get_netrc_auth(url, raise_errors=False): ri = urlparse(url) # Strip port numbers from netloc - host = ri.netloc.split(':')[0] + if isinstance(url, str): + host = ri.netloc.split(u':')[0] + else: + host = ri.netloc.split(b':')[0] try: _netrc = netrc(netrc_path).authenticators(host)