Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/gitdb/utils/encoding.py: 75%

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

12 statements  

1def force_bytes(data, encoding="utf-8"): 

2 if isinstance(data, bytes): 

3 return data 

4 

5 if isinstance(data, str): 

6 return data.encode(encoding) 

7 

8 return data 

9 

10 

11def force_text(data, encoding="utf-8"): 

12 if isinstance(data, str): 

13 return data 

14 

15 if isinstance(data, bytes): 

16 return data.decode(encoding) 

17 

18 return str(data, encoding)