1313
1414from .encoding import DEFAULT_ENCODING
1515
16- def no_code (x , encoding = None ):
17- return x
1816
1917def decode (s , encoding = None ):
2018 encoding = encoding or DEFAULT_ENCODING
@@ -44,7 +42,7 @@ def buffer_to_bytes(buf):
4442def _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=''):
156149builtin_mod_name = "builtins"
157150import 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
170153which = shutil .which
171154
0 commit comments