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

Method __tostr

magic/compat.py:118–126  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

116
117 @staticmethod
118 def __tostr(s):
119 if s is None:
120 return None
121 if isinstance(s, str):
122 return s
123 try: # keep Python 2 compatibility
124 return str(s, 'utf-8')
125 except TypeError:
126 return str(s)
127
128 @staticmethod
129 def __tobytes(b):

Callers 4

fileMethod · 0.80
descriptorMethod · 0.80
bufferMethod · 0.80
errorMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected