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-
12- try :
13- from collections .abc import Iterable
14- except ImportError :
15- from collections import Iterable
16-
17-
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-
297def with_metaclass (meta , * bases ):
308 class metaclass (meta ):
319 __call__ = type .__call__
@@ -39,25 +17,13 @@ def __new__(cls, name, this_bases, d):
3917 return metaclass ('temporary_class' , None , {})
4018
4119
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-
5220def _recursive_repr (item ):
5321 """Hack around python `repr` to deterministically represent dictionaries.
5422
5523 This is able to represent more things than json.dumps, since it does not require
5624 things to be JSON serializable (e.g. datetimes).
5725 """
58- if isinstance (item , basestring ):
59- result = str (item )
60- elif isinstance (item , list ):
26+ if isinstance (item , list ):
6127 result = '[{}]' .format (', ' .join ([_recursive_repr (x ) for x in item ]))
6228 elif isinstance (item , dict ):
6329 kv_pairs = [
0 commit comments