|
24 | 24 | urlunsplit, |
25 | 25 | ) |
26 | 26 | from urllib.request import pathname2url, url2pathname |
27 | | -from w3lib.util import to_bytes, to_native_str, to_unicode |
| 27 | +from w3lib.util import to_bytes, to_unicode |
28 | 28 |
|
29 | 29 |
|
30 | 30 | # error handling function for bytes-to-Unicode decoding errors with URLs |
@@ -85,13 +85,13 @@ def safe_url_string(url, encoding='utf8', path_encoding='utf8', quote_path=True) |
85 | 85 | if quote_path: |
86 | 86 | path = quote(to_bytes(parts.path, path_encoding), _path_safe_chars) |
87 | 87 | else: |
88 | | - path = to_native_str(parts.path) |
| 88 | + path = to_unicode(parts.path) |
89 | 89 |
|
90 | 90 | # quote() in Python2 return type follows input type; |
91 | 91 | # quote() in Python3 always returns Unicode (native str) |
92 | 92 | return urlunsplit(( |
93 | | - to_native_str(parts.scheme), |
94 | | - to_native_str(netloc).rstrip(':'), |
| 93 | + to_unicode(parts.scheme), |
| 94 | + to_unicode(netloc).rstrip(':'), |
95 | 95 | path, |
96 | 96 | # encoding of query and fragment follows page encoding |
97 | 97 | # or form-charset (if known and passed) |
@@ -415,8 +415,8 @@ def _safe_ParseResult(parts, encoding='utf8', path_encoding='utf8'): |
415 | 415 | netloc = parts.netloc |
416 | 416 |
|
417 | 417 | return ( |
418 | | - to_native_str(parts.scheme), |
419 | | - to_native_str(netloc), |
| 418 | + to_unicode(parts.scheme), |
| 419 | + to_unicode(netloc), |
420 | 420 |
|
421 | 421 | # default encoding for path component SHOULD be UTF-8 |
422 | 422 | quote(to_bytes(parts.path, path_encoding), _path_safe_chars), |
|
0 commit comments