1 """Python 3 compatibility shims
4 if sys.version_info[0] < 3:
9 return unicode(s, 'unicode_escape')
10 import cStringIO as StringIO
11 StringIO = BytesIO = StringIO.StringIO
14 string_types = (basestring,)
15 integer_types = (int, long)
17 reload_module = reload
19 return s.decode('hex')
23 if sys.version_info[:2] >= (3, 4):
24 from importlib import reload as reload_module
26 from imp import reload as reload_module
29 return codecs.latin_1_encode(s)[0]
33 StringIO = io.StringIO
38 integer_types = (int,)
44 return bytes.fromhex(s)
46 long_type = integer_types[-1]