aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-24 06:36:47 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-24 06:36:47 +0000
commit90cbb047d50a79d9bdb51b77ef944d9fb4097917 (patch)
tree59cfda8b87a176923a882df9feb7184f57f16f8f /bin/filter-bash-environment.py
parentDecode directory names where appropriate in digestcheck(). Thanks to (diff)
downloadportage-90cbb047d50a79d9bdb51b77ef944d9fb4097917.tar.gz
portage-90cbb047d50a79d9bdb51b77ef944d9fb4097917.tar.bz2
portage-90cbb047d50a79d9bdb51b77ef944d9fb4097917.zip
Avoid unicode errors in python 3. Thanks to Arfrever for reporting.
svn path=/main/trunk/; revision=14400
Diffstat (limited to 'bin/filter-bash-environment.py')
-rwxr-xr-xbin/filter-bash-environment.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py
index 11419fddc..eedb06097 100755
--- a/bin/filter-bash-environment.py
+++ b/bin/filter-bash-environment.py
@@ -3,6 +3,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+import codecs
import os, re, sys
here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
@@ -112,6 +113,13 @@ if __name__ == "__main__":
parser.error("Missing required PATTERN argument.")
file_in = sys.stdin
file_out = sys.stdout
+ if sys.hexversion >= 0x3000000:
+ file_in = codecs.iterdecode(sys.stdin.buffer.raw,
+ 'utf_8', errors='replace')
+ import io
+ file_out = io.TextIOWrapper(sys.stdout.buffer,
+ 'utf_8', errors='backslashreplace')
+
var_pattern = args[0].split()
# Filter invalid variable names that are not supported by bash.