summaryrefslogtreecommitdiff
path: root/magic.py
diff options
context:
space:
mode:
authorTravis Shirk <travis@pobox.com>2017-09-26 19:16:47 -0600
committerTravis Shirk <travis@pobox.com>2017-09-26 19:16:47 -0600
commitae77035e79a74f38437407c29a3966cfcad7d1ae (patch)
tree2d8f40b11d7d51f2e69b20a85b8b347e7300c557 /magic.py
parentcf029d7cb3786754d35194fbbdc870e8f54711cd (diff)
downloadpython-magic-ae77035e79a74f38437407c29a3966cfcad7d1ae.tar.gz
Handle incorrectly encoded files (i.e. does not match file system
encoding)
Diffstat (limited to 'magic.py')
-rw-r--r--magic.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/magic.py b/magic.py
index a97e929..5df5156 100644
--- a/magic.py
+++ b/magic.py
@@ -213,7 +213,7 @@ def coerce_filename(filename):
(sys.version_info[0] >= 3 and
isinstance(filename, str))
if is_unicode:
- return filename.encode('utf-8')
+ return filename.encode('utf-8', 'surrogateescape')
else:
return filename