summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-27 17:18:57 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-27 17:18:57 -0800
commit4021d5a9723b353823ba52cb5e9080de3acf7b68 (patch)
tree02b1b8e2f03e08658fab553a51701210d8b1791f
parentrepoman: remove obsolete RMD160 requirement (diff)
downloadportage-4021d5a9723b353823ba52cb5e9080de3acf7b68.tar.gz
portage-4021d5a9723b353823ba52cb5e9080de3acf7b68.tar.bz2
portage-4021d5a9723b353823ba52cb5e9080de3acf7b68.zip
Add chown workaround for python in Fedora 18.
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.
-rw-r--r--pym/portage/__init__.py27
-rw-r--r--pym/portage/data.py4
2 files changed, 28 insertions, 3 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 94ca7b90f..a8b692c1d 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -224,7 +224,7 @@ class _unicode_func_wrapper(object):
self._func = func
self._encoding = encoding
- def __call__(self, *args, **kwargs):
+ def _process_args(self, args, kwargs):
encoding = self._encoding
wrapped_args = [_unicode_encode(x, encoding=encoding, errors='strict')
@@ -236,6 +236,13 @@ class _unicode_func_wrapper(object):
else:
wrapped_kwargs = {}
+ return (wrapped_args, wrapped_kwargs)
+
+ def __call__(self, *args, **kwargs):
+
+ encoding = self._encoding
+ wrapped_args, wrapped_kwargs = self._process_args(args, kwargs)
+
rval = self._func(*wrapped_args, **wrapped_kwargs)
# Don't use isinstance() since we don't want to convert subclasses
@@ -259,6 +266,23 @@ 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.
@@ -302,6 +326,7 @@ 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,
diff --git a/pym/portage/data.py b/pym/portage/data.py
index 29292f57e..422dea22f 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -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 *** ")