MCPcopy Create free account
hub / github.com/ahupp/python-magic / __tobytes

Method __tobytes

magic/compat.py:129–137  ·  view source on GitHub ↗
(b)

Source from the content-addressed store, hash-verified

127
128 @staticmethod
129 def __tobytes(b):
130 if b is None:
131 return None
132 if isinstance(b, bytes):
133 return b
134 try: # keep Python 2 compatibility
135 return bytes(b, 'utf-8')
136 except TypeError:
137 return bytes(b)
138
139 def file(self, filename):
140 """

Callers 5

fileMethod · 0.80
loadMethod · 0.80
compileMethod · 0.80
checkMethod · 0.80
listMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected