cheroot._compat module#

Compatibility code for using Cheroot with various versions of Python.

cheroot._compat.assert_native(n)#

Check whether the input is of native str type.

Raises:

TypeError: in case of failed check

cheroot._compat.bton(b, encoding='ISO-8859-1')#

Return the byte string as native string in the given encoding.

cheroot._compat.extract_bytes(mv)#

Retrieve bytes out of the given input buffer.

Parameters

mv (memoryview or bytes) – input buffer()

Returns

unwrapped bytes

Return type

bytes

Raises

ValueError – if the input is not one of memoryview/buffer() or bytes

cheroot._compat.ntob(n, encoding='ISO-8859-1')#

Return the native string as bytes in the given encoding.

cheroot._compat.ntou(n, encoding='ISO-8859-1')#

Return the native string as Unicode with the given encoding.