From: Zac Medico Date: Mon, 28 Jan 2013 01:18:57 +0000 (-0800) Subject: Add chown workaround for python in Fedora 18. X-Git-Tag: v2.2.0_alpha162~31 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4021d5a9723b353823ba52cb5e9080de3acf7b68;p=portage.git 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. --- 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 *** ")