Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r15171 - main/branches/prefix/pym/portage
Date: Tue, 05 Jan 2010 19:26:17
Message-Id: E1NSF2l-0002YP-Fc@stork.gentoo.org
1 Author: grobian
2 Date: 2010-01-05 19:26:14 +0000 (Tue, 05 Jan 2010)
3 New Revision: 15171
4
5 Modified:
6 main/branches/prefix/pym/portage/__init__.py
7 main/branches/prefix/pym/portage/exception.py
8 main/branches/prefix/pym/portage/util.py
9 Log:
10 Merged from trunk -r15166:15169
11
12 | 15167 | Rearrange _selinux ImportError handling so the workaround |
13 | zmedico | for bug #298310 isn't necessary. |
14
15 | 15168 | Handle AttributeError inside atomic_ofstream.__del__. Thanks |
16 | zmedico | to Cardoe for reporting. |
17
18 | 15169 | In python-2.x, convert PortageException.value attribute from |
19 | zmedico | unicode to str in order to avoid empty output with string |
20 | | format operator. |
21
22
23 Modified: main/branches/prefix/pym/portage/__init__.py
24 ===================================================================
25 --- main/branches/prefix/pym/portage/__init__.py 2010-01-05 19:23:45 UTC (rev 15170)
26 +++ main/branches/prefix/pym/portage/__init__.py 2010-01-05 19:26:14 UTC (rev 15171)
27 @@ -289,23 +289,19 @@
28 shutil = _unicode_module_wrapper(_shutil, encoding=_encodings['fs'])
29
30 # Imports below this point rely on the above unicode wrapper definitions.
31 -_selinux = None
32 -selinux = None
33 -_selinux_merge = None
34 try:
35 import portage._selinux
36 - # Make sure the _selinux attribute is correctly reinitialized after
37 - # reload(portage) is called. See bug #298310.
38 - _selinux = sys.modules['portage._selinux']
39 selinux = _unicode_module_wrapper(_selinux,
40 encoding=_encodings['fs'])
41 _selinux_merge = _unicode_module_wrapper(_selinux,
42 encoding=_encodings['merge'])
43 -except OSError as e:
44 - sys.stderr.write("!!! SELinux not loaded: %s\n" % str(e))
45 +except (ImportError, OSError) as e:
46 + if isinstance(e, OSError):
47 + sys.stderr.write("!!! SELinux not loaded: %s\n" % str(e))
48 del e
49 -except ImportError:
50 - pass
51 + _selinux = None
52 + selinux = None
53 + _selinux_merge = None
54
55 from portage.manifest import Manifest
56
57
58 Modified: main/branches/prefix/pym/portage/exception.py
59 ===================================================================
60 --- main/branches/prefix/pym/portage/exception.py 2010-01-05 19:23:45 UTC (rev 15170)
61 +++ main/branches/prefix/pym/portage/exception.py 2010-01-05 19:26:14 UTC (rev 15171)
62 @@ -3,6 +3,7 @@
63 # $Id$
64
65 import sys
66 +from portage import _unicode_encode
67 from portage.localization import _
68
69 if sys.hexversion >= 0x3000000:
70 @@ -12,6 +13,10 @@
71 """General superclass for portage exceptions"""
72 def __init__(self,value):
73 self.value = value[:]
74 + if sys.hexversion < 0x3000000 and isinstance(self.value, unicode):
75 + # Workaround for string formatting operator and unicode value
76 + # attribute triggering empty output in formatted string.
77 + self.value = _unicode_encode(self.value)
78 def __str__(self):
79 if isinstance(self.value, basestring):
80 return self.value
81
82 Modified: main/branches/prefix/pym/portage/util.py
83 ===================================================================
84 --- main/branches/prefix/pym/portage/util.py 2010-01-05 19:23:45 UTC (rev 15170)
85 +++ main/branches/prefix/pym/portage/util.py 2010-01-05 19:26:14 UTC (rev 15171)
86 @@ -1010,9 +1010,13 @@
87 def __del__(self):
88 """If the user does not explicitely call close(), it is
89 assumed that an error has occurred, so we abort()."""
90 - f = object.__getattribute__(self, '_file')
91 - if not f.closed:
92 - self.abort()
93 + try:
94 + f = object.__getattribute__(self, '_file')
95 + except AttributeError:
96 + pass
97 + else:
98 + if not f.closed:
99 + self.abort()
100 # ensure destructor from the base class is called
101 base_destructor = getattr(ObjectProxy, '__del__', None)
102 if base_destructor is not None: