Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/simplejson-3.20.1-py3.11-linux-x86_64.egg/simplejson/compat.py: 47%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

30 statements  

1"""Python 3 compatibility shims 

2""" 

3import sys 

4if sys.version_info[0] < 3: 

5 PY3 = False 

6 def b(s): 

7 return s 

8 try: 

9 from cStringIO import StringIO 

10 except ImportError: 

11 from StringIO import StringIO 

12 BytesIO = StringIO 

13 text_type = unicode 

14 binary_type = str 

15 string_types = (basestring,) 

16 integer_types = (int, long) 

17 unichr = unichr 

18 reload_module = reload 

19else: 

20 PY3 = True 

21 if sys.version_info[:2] >= (3, 4): 

22 from importlib import reload as reload_module 

23 else: 

24 from imp import reload as reload_module 

25 def b(s): 

26 return bytes(s, 'latin1') 

27 from io import StringIO, BytesIO 

28 text_type = str 

29 binary_type = bytes 

30 string_types = (str,) 

31 integer_types = (int,) 

32 unichr = chr 

33 

34long_type = integer_types[-1]