diff options
author | Brian Dolbec <dolsen@gentoo.org> | 2014-08-03 08:08:18 -0700 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2014-08-03 08:19:25 -0700 |
commit | 9351edad48523bb38b1bf651506786bdc8814f62 (patch) | |
tree | 9a47ec7558c0f564fc7be426a67e35d40559952d | |
parent | pym/_emerge/Binpkg.py: Add missing line feed to output. (diff) | |
download | portage-2.2.11.tar.gz portage-2.2.11.tar.bz2 portage-2.2.11.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-x | bin/chpathtool.py | 9 |
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): |