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')
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
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.
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,
# 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
" 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 *** ")