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

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

28 statements  

1"""Python 3 compatibility shims 

2""" 

3import sys 

4 

5if sys.version_info[0] < 3: 

6 PY3 = False 

7 def b(s): 

8 return s 

9 try: 

10 from cStringIO import StringIO 

11 except ImportError: 

12 from StringIO import StringIO 

13 BytesIO = StringIO 

14 text_type = unicode 

15 binary_type = str 

16 string_types = (basestring,) 

17 integer_types = (int, long) 

18 unichr = unichr 

19 reload_module = reload 

20else: 

21 PY3 = True 

22 from importlib import reload as reload_module 

23 def b(s): 

24 return bytes(s, 'latin1') 

25 from io import StringIO, BytesIO 

26 text_type = str 

27 binary_type = bytes 

28 string_types = (str,) 

29 integer_types = (int,) 

30 unichr = chr 

31 

32long_type = integer_types[-1]