MCPcopy
hub / github.com/benoitc/gunicorn / to_bytestring

Function to_bytestring

gunicorn/util.py:613–620  ·  view source on GitHub ↗

Converts a string argument to a byte string

(value, encoding="utf8")

Source from the content-addressed store, hash-verified

611
612
613def to_bytestring(value, encoding="utf8"):
614 """Converts a string argument to a byte string"""
615 if isinstance(value, bytes):
616 return value
617 if not isinstance(value, str):
618 raise TypeError('%r is not a string' % value)
619
620 return value.encode(encoding)
621
622
623def has_fileno(obj):

Callers 1

make_fail_appFunction · 0.85

Calls 1

encodeMethod · 0.80

Tested by

no test coverage detected