Remove unused compat.native_str

This commit is contained in:
Chris Hunt 2019-11-10 18:05:25 -05:00
parent 19397d0d2e
commit 0a6305a398
2 changed files with 1 additions and 25 deletions

View File

@ -41,7 +41,7 @@ except ImportError:
__all__ = [
"ipaddress", "uses_pycache", "console_to_str", "native_str",
"ipaddress", "uses_pycache", "console_to_str",
"get_path_uid", "stdlib_pkgs", "WINDOWS", "samefile", "get_terminal_size",
"get_extension_suffixes",
]
@ -159,22 +159,6 @@ def console_to_str(data):
return str_to_display(data, desc='Subprocess output')
if PY2:
def native_str(s, replace=False):
# type: (str, bool) -> str
# Replace is ignored -- unicode to UTF-8 can't fail
if isinstance(s, text_type):
return s.encode('utf-8')
return s
else:
def native_str(s, replace=False):
# type: (str, bool) -> str
if isinstance(s, bytes):
return s.decode('utf-8', 'replace' if replace else 'strict')
return s
def get_path_uid(path):
# type: (str) -> int
"""

View File

@ -10,7 +10,6 @@ from pip._internal.utils.compat import (
console_to_str,
expanduser,
get_path_uid,
native_str,
str_to_display,
)
@ -128,13 +127,6 @@ def test_console_to_str_warning(monkeypatch):
console_to_str(some_bytes)
def test_to_native_str_type():
some_bytes = b"test\xE9 et approuv\xC3\xE9"
some_unicode = b"test\xE9 et approuv\xE9".decode('iso-8859-15')
assert isinstance(native_str(some_bytes, True), str)
assert isinstance(native_str(some_unicode, True), str)
@pytest.mark.parametrize("home,path,expanded", [
("/Users/test", "~", "/Users/test"),
("/Users/test", "~/.cache", "/Users/test/.cache"),