Check for bytes instead of unicode in args.
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Oct 2011 20:13:07 +0000 (13:13 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Oct 2011 20:13:07 +0000 (13:13 -0700)
This simplifies the checks since the bytes type is available in all
supported python versions, while the unicode type is only available in
python2.

bin/lock-helper.py
bin/portageq
pym/_emerge/main.py

index 5f3ea9f0955665c459614ab923905a6c8e3d404c..065ddcbc42e5c9dc3d5df8b2ce4cd290b5f07955 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import os
@@ -9,7 +9,7 @@ import portage
 
 def main(args):
 
-       if args and sys.hexversion < 0x3000000 and not isinstance(args[0], unicode):
+       if args and isinstance(args[0], bytes):
                for i, x in enumerate(args):
                        args[i] = portage._unicode_decode(x, errors='strict')
 
index 02f19040ce84e67a95b04e0543200af8d13d5a4e..40cc21d27472a3ffb2016e660d155d03caf6c7db 100755 (executable)
@@ -847,7 +847,7 @@ def main():
                os.environ["ROOT"] = root
 
        args = sys.argv[2:]
-       if args and sys.hexversion < 0x3000000 and not isinstance(args[0], unicode):
+       if args and isinstance(args[0], bytes):
                for i in range(len(args)):
                        args[i] = portage._unicode_decode(args[i])
 
index 0dfc5f9985edafe8afef09046e815934774b849c..162f70ffdb44f1d1f4e776be973d603a34430ebe 100644 (file)
@@ -1233,8 +1233,7 @@ def parse_opts(tmpcmdline, silent=False):
        if myaction is None and myoptions.deselect is True:
                myaction = 'deselect'
 
-       if myargs and sys.hexversion < 0x3000000 and \
-               not isinstance(myargs[0], unicode):
+       if myargs and isinstance(myargs[0], bytes):
                for i in range(len(myargs)):
                        myargs[i] = portage._unicode_decode(myargs[i])