Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a089b78

Browse files
committed
Code Cleanup: Remove unused unused utility functions from 'IPython/utils/py3compat.py' #11985
1 parent 875db0e commit a089b78

1 file changed

Lines changed: 3 additions & 20 deletions

File tree

IPython/utils/py3compat.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
from .encoding import DEFAULT_ENCODING
1515

16-
def no_code(x, encoding=None):
17-
return x
1816

1917
def decode(s, encoding=None):
2018
encoding = encoding or DEFAULT_ENCODING
@@ -44,7 +42,7 @@ def buffer_to_bytes(buf):
4442
def _modify_str_or_docstring(str_change_func):
4543
@functools.wraps(str_change_func)
4644
def wrapper(func_or_str):
47-
if isinstance(func_or_str, string_types):
45+
if isinstance(func_or_str, (str,)):
4846
func = None
4947
doc = func_or_str
5048
else:
@@ -66,17 +64,12 @@ def safe_unicode(e):
6664
safe to call unicode() on.
6765
"""
6866
try:
69-
return unicode_type(e)
67+
return str(e)
7068
except UnicodeError:
7169
pass
7270

7371
try:
74-
return str_to_unicode(str(e))
75-
except UnicodeError:
76-
pass
77-
78-
try:
79-
return str_to_unicode(repr(e))
72+
return repr(e)
8073
except UnicodeError:
8174
pass
8275

@@ -156,16 +149,6 @@ def input(prompt=''):
156149
builtin_mod_name = "builtins"
157150
import builtins as builtin_mod
158151

159-
str_to_unicode = no_code
160-
unicode_to_str = no_code
161-
str_to_bytes = encode
162-
bytes_to_str = decode
163-
cast_bytes_py2 = no_code
164-
cast_unicode_py2 = no_code
165-
buffer_to_bytes_py2 = no_code
166-
167-
string_types = (str,)
168-
unicode_type = str
169152

170153
which = shutil.which
171154

0 commit comments

Comments
 (0)