diff options
Diffstat (limited to 'magic.py')
| -rw-r--r-- | magic.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -72,6 +72,11 @@ class Magic: """ with self.lock: try: + # if we're on python3, convert buf to bytes + # otherwise this string is passed as wchar* + # which is not what libmagic expects + if type(buf) == str and str != bytes: + buf = buf.encode('utf-8', errors='replace') return maybe_decode(magic_buffer(self.cookie, buf)) except MagicException as e: return self._handle509Bug(e) |
