Cast uid/gid proxies to int for Python 3.4.
authorZac Medico <zmedico@gentoo.org>
Sun, 11 Aug 2013 22:00:30 +0000 (15:00 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 11 Aug 2013 22:00:30 +0000 (15:00 -0700)
See http://hg.python.org/cpython/rev/f871f8662509.

pym/portage/__init__.py
pym/portage/cache/fs_template.py
pym/portage/data.py
pym/portage/locks.py
pym/portage/package/ebuild/doebuild.py
pym/portage/process.py
pym/portage/util/__init__.py

index 13a34e695f15228932b2956ea65e5bf34b03f055..75d0d6437d3232cc8bf9627fa2ad5cd0b12e73b1 100644 (file)
@@ -279,23 +279,6 @@ class _unicode_func_wrapper(object):
 
                return rval
 
-class _chown_func_wrapper(_unicode_func_wrapper):
-       """
-       Compatibility workaround for Python 2.7.3 in Fedora 18, which throws
-       "TypeError: group id must be integer" if we try to pass an ObjectProxy
-       instance into chown.
-       """
-
-       def _process_args(self, args, kwargs):
-
-               wrapped_args, wrapped_kwargs = \
-                       _unicode_func_wrapper._process_args(self, args, kwargs)
-
-               for i in (1, 2):
-                       wrapped_args[i] = int(wrapped_args[i])
-
-               return (wrapped_args, wrapped_kwargs)
-
 class _unicode_module_wrapper(object):
        """
        Wraps a module and wraps all functions with _unicode_func_wrapper.
@@ -339,7 +322,6 @@ class _unicode_module_wrapper(object):
 
 import os as _os
 _os_overrides = {
-       id(_os.chown)         : _chown_func_wrapper(_os.chown),
        id(_os.fdopen)        : _os.fdopen,
        id(_os.popen)         : _os.popen,
        id(_os.read)          : _os.read,
index 8f0636ed013bd3b75f5c39c47b774b46f09f1ed2..0567c72b9abc05f5bff14b35417aa486c9a68c4f 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2005-2012 Gentoo Foundation
+# Copyright 2005-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # Author(s): Brian Harring (ferringb@gentoo.org)
 
@@ -25,7 +25,8 @@ class FsBased(template.database):
 
                for x, y in (("gid", -1), ("perms", -1)):
                        if x in config:
-                               setattr(self, "_"+x, config[x])
+                               # Since Python 3.4, chown requires int type (no proxies).
+                               setattr(self, "_" + x, int(config[x]))
                                del config[x]
                        else:
                                setattr(self, "_"+x, y)
index caf4752ac2b04849ee99ef13d9d2eff379956e8a..44104c273d49dee002656fa50bfd3b52495034c9 100644 (file)
@@ -32,7 +32,7 @@ if not lchown:
                                " exist.  Please rebuild python.\n"), noiselevel=-1)
                lchown()
 
-lchown = portage._chown_func_wrapper(lchown)
+lchown = portage._unicode_func_wrapper(lchown)
 
 def portage_group_warning():
        warn_prefix = colorize("BAD", "*** WARNING ***  ")
index 71bce305ac911495ad52ce06c3898d4d9227a661..87aaf94a21fd02c9952f96a641796512a0fab6d3 100644 (file)
@@ -17,7 +17,6 @@ import portage
 from portage import os, _encodings, _unicode_decode
 from portage.exception import DirectoryNotFound, FileNotFound, \
        InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
-from portage.data import portage_gid
 from portage.util import writemsg
 from portage.localization import _
 
@@ -64,6 +63,9 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
        if not mypath:
                raise InvalidData(_("Empty path given"))
 
+       # Since Python 3.4, chown requires int type (no proxies).
+       portage_gid = int(portage.data.portage_gid)
+
        # Support for file object or integer file descriptor parameters is
        # deprecated due to ambiguity in whether or not it's safe to close
        # the file descriptor, making it prone to "Bad file descriptor" errors
@@ -372,6 +374,9 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
        preexisting = os.path.exists(lockfilename)
        myhardlock = hardlock_name(lockfilename)
 
+       # Since Python 3.4, chown requires int type (no proxies).
+       portage_gid = int(portage.data.portage_gid)
+
        # myhardlock must not exist prior to our link() call, and we can
        # safely unlink it since its file name is unique to our PID
        try:
index 667280ecd25d9f4faf7aa14d6a7a173f4696aeb3..1cf5dc6aec553b949358f9ee5fd8919688a29a5c 100644 (file)
@@ -1459,8 +1459,10 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
                                "umask": 0o02
                        })
                if "userpriv" in features and "userpriv" not in mysettings["PORTAGE_RESTRICT"].split() and secpass >= 2:
-                       portage_build_uid = portage_uid
-                       portage_build_gid = portage_gid
+                       # Since Python 3.4, getpwuid and getgrgid
+                       # require int type (no proxies).
+                       portage_build_uid = int(portage_uid)
+                       portage_build_gid = int(portage_gid)
 
        if "PORTAGE_BUILD_USER" not in mysettings:
                user = None
index 92f2aba0c548b185a5ec1802c9e7a02008a06fa3..5f6a172e0008b153e0c68749289c9af55401bb59 100644 (file)
@@ -417,11 +417,13 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
 
        # Set requested process permissions.
        if gid:
-               os.setgid(gid)
+               # Cast proxies to int, in case it matters.
+               os.setgid(int(gid))
        if groups:
                os.setgroups(groups)
        if uid:
-               os.setuid(uid)
+               # Cast proxies to int, in case it matters.
+               os.setuid(int(uid))
        if umask:
                os.umask(umask)
        if pre_exec:
index 546262e68bcc652d7927bec44c4858d283bf3a1e..92a218793e49a4b5946c4f9fdf40ecebb213811e 100644 (file)
@@ -1014,6 +1014,10 @@ def apply_permissions(filename, uid=-1, gid=-1, mode=-1, mask=-1,
 
        modified = False
 
+       # Since Python 3.4, chown requires int type (no proxies).
+       uid = int(uid)
+       gid = int(gid)
+
        if stat_cached is None:
                try:
                        if follow_links: