11from __future__ import unicode_literals
22from builtins import str
3- from past .builtins import basestring
43import hashlib
54import sys
65
76
8- if sys .version_info .major == 2 :
9- # noinspection PyUnresolvedReferences,PyShadowingBuiltins
10- str = str
11-
127try :
138 from collections .abc import Iterable
149except ImportError :
1510 from collections import Iterable
1611
1712
18- # `past.builtins.basestring` module can't be imported on Python3 in some environments (Ubuntu).
19- # This code is copy-pasted from it to avoid crashes.
20- class BaseBaseString (type ):
21- def __instancecheck__ (cls , instance ):
22- return isinstance (instance , (bytes , str ))
23-
24- def __subclasshook__ (cls , thing ):
25- # TODO: What should go here?
26- raise NotImplemented
27-
28-
2913def with_metaclass (meta , * bases ):
3014 class metaclass (meta ):
3115 __call__ = type .__call__
@@ -39,25 +23,13 @@ def __new__(cls, name, this_bases, d):
3923 return metaclass ('temporary_class' , None , {})
4024
4125
42- if sys .version_info .major >= 3 :
43-
44- class basestring (with_metaclass (BaseBaseString )):
45- pass
46-
47- else :
48- # noinspection PyUnresolvedReferences,PyCompatibility
49- from builtins import basestring
50-
51-
5226def _recursive_repr (item ):
5327 """Hack around python `repr` to deterministically represent dictionaries.
5428
5529 This is able to represent more things than json.dumps, since it does not require
5630 things to be JSON serializable (e.g. datetimes).
5731 """
58- if isinstance (item , basestring ):
59- result = str (item )
60- elif isinstance (item , list ):
32+ if isinstance (item , list ):
6133 result = '[{}]' .format (', ' .join ([_recursive_repr (x ) for x in item ]))
6234 elif isinstance (item , dict ):
6335 kv_pairs = [
0 commit comments