aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2014-08-03 08:08:18 -0700
committerBrian Dolbec <dolsen@gentoo.org>2014-08-03 08:19:25 -0700
commit9351edad48523bb38b1bf651506786bdc8814f62 (patch)
tree9a47ec7558c0f564fc7be426a67e35d40559952d
parentpym/_emerge/Binpkg.py: Add missing line feed to output. (diff)
downloadportage-9351edad48523bb38b1bf651506786bdc8814f62.tar.gz
portage-9351edad48523bb38b1bf651506786bdc8814f62.tar.bz2
portage-9351edad48523bb38b1bf651506786bdc8814f62.zip
bin/chpathtool.py: fix py3.2 &py3.3 test failurev2.2.11
The magic module for those 2 python versions do not handle byte strings correctly. forcing the filename to str() fixes it for all pythons tested.
-rwxr-xr-xbin/chpathtool.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/chpathtool.py b/bin/chpathtool.py
index 64606623a..6ddf329e8 100755
--- a/bin/chpathtool.py
+++ b/bin/chpathtool.py
@@ -51,9 +51,12 @@ class IsTextFile(object):
return self._call(filename)
def _is_text_magic(self, filename):
- mime_type = self._m.file(filename)
- if isinstance(mime_type, bytes):
- mime_type = mime_type.decode('ascii', 'replace')
+ # regression in sys-apps/file causes
+ # py 3.2 & 3.3 magic module to not handle bytes properly
+ if isinstance(filename, bytes):
+ mime_type = self._m.file(str(filename))
+ else:
+ mime_type = self._m.file(filename)
return mime_type.startswith('text/')
def _is_text_encoding(self, filename):