cheroot._compat module

Compatibility code for using Cheroot with various versions of Python.

cheroot._compat.assert_native(n)

Check whether the input is of nativ 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 memoryview/buffer or bytes.

class cheroot._compat.memoryview

Bases: object

Create a new memoryview object which references the given object.

c_contiguous

A bool indicating whether the memory is C contiguous.

cast()

Cast a memoryview to a new format or shape.

contiguous

A bool indicating whether the memory is contiguous.

f_contiguous

A bool indicating whether the memory is Fortran contiguous.

format

A string containing the format (in struct module style) for each element in the view.

hex()

Return the data in the buffer as a string of hexadecimal numbers.

itemsize

The size in bytes of each element of the memoryview.

nbytes

The amount of space in bytes that the array would use in a contiguous representation.

ndim

An integer indicating how many dimensions of a multi-dimensional array the memory represents.

obj

The underlying object of the memoryview.

readonly

A bool indicating whether the memory is read only.

release()

Release the underlying buffer exposed by the memoryview object.

shape

A tuple of ndim integers giving the shape of the memory as an N-dimensional array.

strides

A tuple of ndim integers giving the size in bytes to access each element for each dimension of the array.

suboffsets

A tuple of integers used internally for PIL-style arrays.

tobytes()

Return the data in the buffer as a byte string.

tolist()

Return the data in the buffer as a list of elements.

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.

Indices and tables