Skip to content

Commit 97b6da4

Browse files
committed
tmp
1 parent a0c3942 commit 97b6da4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

w3lib/http.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from base64 import urlsafe_b64encode
22
from typing import Any, List, MutableMapping, Optional, AnyStr, Sequence, Union, Mapping
3-
from w3lib.util import to_bytes
3+
from w3lib.encoding import to_unicode
4+
from w3lib.util import to_bytes, to_native_str
45

56
HeadersDictInput = Mapping[bytes, Union[Any, Sequence]]
67
HeadersDictOutput = MutableMapping[bytes, List[bytes]]
@@ -95,7 +96,7 @@ def basic_auth_header(username: AnyStr, password: AnyStr, encoding: str = 'ISO-8
9596
9697
"""
9798

98-
auth = "%r:%r" % (username, password)
99+
auth = "%s:%s" % (to_native_str(username), to_native_str(password))
99100
# XXX: RFC 2617 doesn't define encoding, but ISO-8859-1
100101
# seems to be the most widely used encoding here. See also:
101102
# http://greenbytes.de/tech/webdav/draft-ietf-httpauth-basicauth-enc-latest.html

w3lib/url.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,11 @@ def parse_data_uri(uri: StrOrBytes) -> _ParseDataURIResult:
411411
]
412412

413413

414-
def _safe_ParseResult(parts, encoding='utf8', path_encoding='utf8'):
414+
def _safe_ParseResult(parts: ParseResult, encoding: str = 'utf8', path_encoding: str = 'utf8') -> Tuple[str, str, str, str, str, str]:
415415
# IDNA encoding can fail for too long labels (>63 characters)
416416
# or missing labels (e.g. http://.example.com)
417417
try:
418-
netloc = parts.netloc.encode('idna').decode()
418+
netloc: StrOrBytes = parts.netloc.encode('idna')
419419
except UnicodeError:
420420
netloc = parts.netloc
421421

@@ -531,7 +531,7 @@ def _unquotepath(path):
531531
return unquote_to_bytes(path)
532532

533533

534-
def parse_url(url, encoding=None):
534+
def parse_url(url: Union[StrOrBytes, ParseResult], encoding=None):
535535
"""Return urlparsed url from the given argument (which could be an already
536536
parsed url)
537537
"""

0 commit comments

Comments
 (0)