Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/
Date: Mon, 28 Jan 2013 01:21:23
Message-Id: 1359335937.4021d5a9723b353823ba52cb5e9080de3acf7b68.zmedico@gentoo
1 commit: 4021d5a9723b353823ba52cb5e9080de3acf7b68
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 28 01:18:57 2013 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 28 01:18:57 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4021d5a9
7
8 Add chown workaround for python in Fedora 18.
9
10 Compatibility workaround for Python 2.7.3 in Fedora 18, which throws
11 "TypeError: group id must be integer" if we try to pass an ObjectProxy
12 instance into chown.
13
14 ---
15 pym/portage/__init__.py | 27 ++++++++++++++++++++++++++-
16 pym/portage/data.py | 4 ++--
17 2 files changed, 28 insertions(+), 3 deletions(-)
18
19 diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
20 index 94ca7b9..a8b692c 100644
21 --- a/pym/portage/__init__.py
22 +++ b/pym/portage/__init__.py
23 @@ -224,7 +224,7 @@ class _unicode_func_wrapper(object):
24 self._func = func
25 self._encoding = encoding
26
27 - def __call__(self, *args, **kwargs):
28 + def _process_args(self, args, kwargs):
29
30 encoding = self._encoding
31 wrapped_args = [_unicode_encode(x, encoding=encoding, errors='strict')
32 @@ -236,6 +236,13 @@ class _unicode_func_wrapper(object):
33 else:
34 wrapped_kwargs = {}
35
36 + return (wrapped_args, wrapped_kwargs)
37 +
38 + def __call__(self, *args, **kwargs):
39 +
40 + encoding = self._encoding
41 + wrapped_args, wrapped_kwargs = self._process_args(args, kwargs)
42 +
43 rval = self._func(*wrapped_args, **wrapped_kwargs)
44
45 # Don't use isinstance() since we don't want to convert subclasses
46 @@ -259,6 +266,23 @@ class _unicode_func_wrapper(object):
47
48 return rval
49
50 +class _chown_func_wrapper(_unicode_func_wrapper):
51 + """
52 + Compatibility workaround for Python 2.7.3 in Fedora 18, which throws
53 + "TypeError: group id must be integer" if we try to pass an ObjectProxy
54 + instance into chown.
55 + """
56 +
57 + def _process_args(self, args, kwargs):
58 +
59 + wrapped_args, wrapped_kwargs = \
60 + _unicode_func_wrapper._process_args(self, args, kwargs)
61 +
62 + for i in (1, 2):
63 + wrapped_args[i] = int(wrapped_args[i])
64 +
65 + return (wrapped_args, wrapped_kwargs)
66 +
67 class _unicode_module_wrapper(object):
68 """
69 Wraps a module and wraps all functions with _unicode_func_wrapper.
70 @@ -302,6 +326,7 @@ class _unicode_module_wrapper(object):
71
72 import os as _os
73 _os_overrides = {
74 + id(_os.chown) : _chown_func_wrapper(_os.chown),
75 id(_os.fdopen) : _os.fdopen,
76 id(_os.popen) : _os.popen,
77 id(_os.read) : _os.read,
78
79 diff --git a/pym/portage/data.py b/pym/portage/data.py
80 index 29292f5..422dea2 100644
81 --- a/pym/portage/data.py
82 +++ b/pym/portage/data.py
83 @@ -1,5 +1,5 @@
84 # data.py -- Calculated/Discovered Data Values
85 -# Copyright 1998-2012 Gentoo Foundation
86 +# Copyright 1998-2013 Gentoo Foundation
87 # Distributed under the terms of the GNU General Public License v2
88
89 import os, pwd, grp, platform, sys
90 @@ -32,7 +32,7 @@ if not lchown:
91 " exist. Please rebuild python.\n"), noiselevel=-1)
92 lchown()
93
94 -lchown = portage._unicode_func_wrapper(lchown)
95 +lchown = portage._chown_func_wrapper(lchown)
96
97 def portage_group_warning():
98 warn_prefix = colorize("BAD", "*** WARNING *** ")