FreeBSD: don't use /dev/fd, bug #478446
[portage.git] / pym / portage / data.py
index 29292f57e3f2afd5448ec78d70dfee78c7a201e2..caf4752ac2b04849ee99ef13d9d2eff379956e8a 100644 (file)
@@ -1,5 +1,5 @@
 # data.py -- Calculated/Discovered Data Values
-# Copyright 1998-2012 Gentoo Foundation
+# Copyright 1998-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import os, pwd, grp, platform, sys
@@ -32,7 +32,7 @@ if not lchown:
                                " exist.  Please rebuild python.\n"), noiselevel=-1)
                lchown()
 
-lchown = portage._unicode_func_wrapper(lchown)
+lchown = portage._chown_func_wrapper(lchown)
 
 def portage_group_warning():
        warn_prefix = colorize("BAD", "*** WARNING ***  ")
@@ -139,12 +139,20 @@ def _get_global(k):
                        # grp.getgrall() since it is known to trigger spurious
                        # SIGPIPE problems with nss_ldap.
                        cmd = ["id", "-G", _portage_username]
+
+                       if sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000:
+                               # Python 3.1 _execvp throws TypeError for non-absolute executable
+                               # path passed as bytes (see http://bugs.python.org/issue8513).
+                               fullname = portage.process.find_binary(cmd[0])
+                               if fullname is None:
+                                       globals()[k] = v
+                                       _initialized_globals.add(k)
+                                       return v
+                               cmd[0] = fullname
+
                        encoding = portage._encodings['content']
-                       if sys.hexversion < 0x3000000 or sys.hexversion >= 0x3020000:
-                               # Python 3.1 does not support bytes in Popen args.
-                               cmd = [portage._unicode_encode(x,
-                                       encoding=encoding, errors='strict')
-                                       for x in cmd]
+                       cmd = [portage._unicode_encode(x,
+                               encoding=encoding, errors='strict') for x in cmd]
                        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT)
                        myoutput = proc.communicate()[0]