Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13922 - in main/branches/prefix: . bin pym/_emerge pym/portage pym/portage/dbapi pym/portage/sets
Date: Wed, 05 Aug 2009 18:10:09
Message-Id: E1MYkwA-0002S9-Va@stork.gentoo.org
1 Author: grobian
2 Date: 2009-08-05 18:10:06 +0000 (Wed, 05 Aug 2009)
3 New Revision: 13922
4
5 Modified:
6 main/branches/prefix/bin/portageq
7 main/branches/prefix/pym/_emerge/Scheduler.py
8 main/branches/prefix/pym/_emerge/main.py
9 main/branches/prefix/pym/portage/__init__.py
10 main/branches/prefix/pym/portage/dbapi/vartree.py
11 main/branches/prefix/pym/portage/dep.py
12 main/branches/prefix/pym/portage/sets/files.py
13 main/branches/prefix/pym/portage/util.py
14 main/branches/prefix/subst-install.in
15 Log:
16 Merged from trunk -r13895:13909
17
18 | 13898 | Bug #280275 - Fix exception: AttributeError: 'config' object |
19 | zmedico | has no attribute '_license_groups'. |
20
21 | 13900 | Avoid UnicodeEncodeError in writemsg(). Thanks to Markos |
22 | zmedico | Chandras <hwoarang@g.o> for reporting. |
23
24 | 13901 | Open log files in text mode (to avoid UnicodeEncodeError). |
25 | zmedico | Thanks to Markos Chandras <hwoarang@g.o> for |
26 | | reporting. |
27
28 | 13902 | Open CONTENTS in text mode (to avoid UnicodeEncodeError). |
29 | zmedico | Thanks to Markos Chandras <hwoarang@g.o> for |
30 | | reporting. |
31
32 | 13903 | Bug #280269 - Fix StaticFileSet.multiBuilder() to handle |
33 | zmedico | unicode filenames. |
34
35 | 13904 | Bug #280269 - Decode commandline arguments to unicode when |
36 | zmedico | necessary. |
37
38 | 13905 | Bug #280269 - Fix Atom.__str__ so that it doesn't try to |
39 | zmedico | encode a unicode string (resulting in UnicodeEncodeError). |
40 | | If an Atom instance is passed into the constructor, just |
41 | | return the given instance. |
42
43 | 13906 | Decode arguments to unicode if necessary (needed at least |
44 | zmedico | for unicode file names passed to the owners command). |
45
46 | 13907 | Always return unicode from vardbapi.aux_get(). |
47 | zmedico | |
48
49 | 13908 | Fix tar_contents() to open files in binary mode for py3k |
50 | zmedico | compatibility. |
51
52 | 13909 | Fix vardbapi._aux_get() to always return unicode. |
53 | zmedico | |
54
55
56 Modified: main/branches/prefix/bin/portageq
57 ===================================================================
58 --- main/branches/prefix/bin/portageq 2009-08-05 18:07:45 UTC (rev 13921)
59 +++ main/branches/prefix/bin/portageq 2009-08-05 18:10:06 UTC (rev 13922)
60 @@ -606,10 +606,15 @@
61 sys.path.insert(0, pym_path)
62 import portage
63
64 + args = sys.argv[2:]
65 + if args and not isinstance(args[0], unicode):
66 + for i in xrange(len(args)):
67 + args[i] = unicode(args[i], encoding='utf_8', errors='replace')
68 +
69 try:
70 if uses_root:
71 - sys.argv[2] = portage.settings["ROOT"]
72 - retval = function(sys.argv[2:])
73 + args[0] = portage.settings["ROOT"]
74 + retval = function(args)
75 if retval:
76 sys.exit(retval)
77 except portage.exception.PermissionDenied, e:
78
79 Modified: main/branches/prefix/pym/_emerge/Scheduler.py
80 ===================================================================
81 --- main/branches/prefix/pym/_emerge/Scheduler.py 2009-08-05 18:07:45 UTC (rev 13921)
82 +++ main/branches/prefix/pym/_emerge/Scheduler.py 2009-08-05 18:10:06 UTC (rev 13922)
83 @@ -2,6 +2,7 @@
84 # Distributed under the terms of the GNU General Public License v2
85 # $Id$
86
87 +import codecs
88 import logging
89 import os
90 import sys
91 @@ -478,7 +479,8 @@
92 return self._pkg(cpv, type_name, root_config, installed=installed)
93
94 def _append_to_log_path(self, log_path, msg):
95 - f = open(log_path, 'a')
96 + f = codecs.open(log_path, mode='a',
97 + encoding='utf_8', errors='replace')
98 try:
99 f.write(msg)
100 finally:
101 @@ -492,7 +494,8 @@
102 background = self._background
103
104 if background and log_path is not None:
105 - log_file = open(log_path, 'a')
106 + log_file = codecs.open(log_path, mode='a',
107 + encoding='utf_8', errors='replace')
108 out = log_file
109
110 try:
111 @@ -867,7 +870,8 @@
112 log_path = self._locate_failure_log(failed_pkg)
113 if log_path is not None:
114 try:
115 - log_file = open(log_path)
116 + log_file = codecs.open(log_path, mode='r',
117 + encoding='utf_8', errors='replace')
118 except IOError:
119 pass
120
121
122 Modified: main/branches/prefix/pym/_emerge/main.py
123 ===================================================================
124 --- main/branches/prefix/pym/_emerge/main.py 2009-08-05 18:07:45 UTC (rev 13921)
125 +++ main/branches/prefix/pym/_emerge/main.py 2009-08-05 18:10:06 UTC (rev 13922)
126 @@ -760,6 +760,10 @@
127 if myaction is None and myoptions.deselect is True:
128 myaction = 'deselect'
129
130 + if myargs and not isinstance(myargs[0], unicode):
131 + for i in xrange(len(myargs)):
132 + myargs[i] = unicode(myargs[i], encoding='utf_8', errors='replace')
133 +
134 myfiles += myargs
135
136 return myaction, myopts, myfiles
137
138 Modified: main/branches/prefix/pym/portage/__init__.py
139 ===================================================================
140 --- main/branches/prefix/pym/portage/__init__.py 2009-08-05 18:07:45 UTC (rev 13921)
141 +++ main/branches/prefix/pym/portage/__init__.py 2009-08-05 18:10:06 UTC (rev 13922)
142 @@ -1212,6 +1212,7 @@
143 self._accept_chost_re = None
144 self._accept_license = None
145 self._accept_license_str = None
146 + self._license_groups = {}
147
148 self.virtuals = {}
149 self.virts_p = {}
150 @@ -1297,6 +1298,7 @@
151
152 self._accept_license = copy.deepcopy(clone._accept_license)
153 self._plicensedict = copy.deepcopy(clone._plicensedict)
154 + self._license_groups = copy.deepcopy(clone._license_groups)
155 else:
156
157 def check_var_directory(varname, var):
158 @@ -1793,7 +1795,6 @@
159 self.pprovideddict[mycatpkg]=[x]
160
161 # parse licensegroups
162 - self._license_groups = {}
163 for x in locations:
164 self._license_groups.update(
165 grabdict(os.path.join(x, "license_groups")))
166
167 Modified: main/branches/prefix/pym/portage/dbapi/vartree.py
168 ===================================================================
169 --- main/branches/prefix/pym/portage/dbapi/vartree.py 2009-08-05 18:07:45 UTC (rev 13921)
170 +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2009-08-05 18:10:06 UTC (rev 13922)
171 @@ -38,6 +38,7 @@
172
173 from portage.cache.mappings import slot_dict_class
174
175 +import codecs
176 import os, re, shutil, stat, errno, copy, subprocess
177 import logging
178 import shlex
179 @@ -1866,6 +1867,12 @@
180 cache_mtime, metadata = pkg_data
181 cache_valid = cache_mtime == mydir_mtime
182 if cache_valid:
183 + for k, v in metadata.iteritems():
184 + if not isinstance(v, unicode):
185 + # Migrate old metadata to unicode.
186 + metadata[k] = unicode(v,
187 + encoding='utf_8', errors='replace')
188 +
189 mydata.update(metadata)
190 pull_me.difference_update(mydata)
191
192 @@ -1886,7 +1893,7 @@
193 if not mydata['SLOT']:
194 # Empty slot triggers InvalidAtom exceptions when generating slot
195 # atoms for packages, so translate it to '0' here.
196 - mydata['SLOT'] = '0'
197 + mydata['SLOT'] = u'0'
198 return [mydata[x] for x in wants]
199
200 def _aux_get(self, mycpv, wants, st=None):
201 @@ -1909,7 +1916,8 @@
202 results.append(long(st.st_mtime))
203 continue
204 try:
205 - myf = open(os.path.join(mydir, x), "r")
206 + myf = codecs.open(os.path.join(mydir, x),
207 + mode='r', encoding='utf_8', errors='replace')
208 try:
209 myd = myf.read()
210 finally:
211 @@ -1919,9 +1927,9 @@
212 if self._aux_multi_line_re.match(x) is None:
213 myd = " ".join(myd.split())
214 except IOError:
215 - myd = ""
216 + myd = u''
217 if x == "EAPI" and not myd:
218 - results.append("0")
219 + results.append(u'0')
220 else:
221 results.append(myd)
222 return results
223 @@ -2558,7 +2566,8 @@
224 return self.contentscache
225 pkgfiles = {}
226 try:
227 - myc = open(contents_file,"r")
228 + myc = codecs.open(contents_file, mode='r',
229 + encoding='utf_8', errors='replace')
230 except EnvironmentError, e:
231 if e.errno != errno.ENOENT:
232 raise
233 @@ -4141,7 +4150,8 @@
234 lcfile.close()
235
236 # open CONTENTS file (possibly overwriting old one) for recording
237 - outfile = open(os.path.join(self.dbtmpdir, "CONTENTS"),"w")
238 + outfile = codecs.open(os.path.join(self.dbtmpdir, 'CONTENTS'),
239 + mode='w', encoding='utf_8', errors='replace')
240
241 self.updateprotect()
242
243 @@ -4846,7 +4856,7 @@
244 tarinfo.size = 0
245 tar.addfile(tarinfo)
246 else:
247 - f = open(path)
248 + f = open(path, 'rb')
249 try:
250 tar.addfile(tarinfo, f)
251 finally:
252
253 Modified: main/branches/prefix/pym/portage/dep.py
254 ===================================================================
255 --- main/branches/prefix/pym/portage/dep.py 2009-08-05 18:07:45 UTC (rev 13921)
256 +++ main/branches/prefix/pym/portage/dep.py 2009-08-05 18:10:06 UTC (rev 13922)
257 @@ -494,6 +494,8 @@
258 identical instances when available.
259 """
260 def __call__(cls, s):
261 + if isinstance(s, Atom):
262 + return s
263 instance = cls._atoms.get(s)
264 if instance is None:
265 instance = super(_AtomCache, cls).__call__(s)
266 @@ -620,7 +622,7 @@
267 return repr(self._str)
268
269 def __str__(self):
270 - return str(self._str)
271 + return self._str
272
273 def endswith(self, *pargs, **kargs):
274 return self._str.endswith(*pargs, **kargs)
275
276 Modified: main/branches/prefix/pym/portage/sets/files.py
277 ===================================================================
278 --- main/branches/prefix/pym/portage/sets/files.py 2009-08-05 18:07:45 UTC (rev 13921)
279 +++ main/branches/prefix/pym/portage/sets/files.py 2009-08-05 18:10:06 UTC (rev 13922)
280 @@ -131,6 +131,9 @@
281 if d[:1] == '.':
282 dirs.remove(d)
283 for filename in files:
284 + if not isinstance(filename, unicode):
285 + filename = unicode(filename,
286 + encoding='utf_8', errors='replace')
287 if filename[:1] == '.':
288 continue
289 if filename.endswith(".metadata"):
290
291 Modified: main/branches/prefix/pym/portage/util.py
292 ===================================================================
293 --- main/branches/prefix/pym/portage/util.py 2009-08-05 18:07:45 UTC (rev 13921)
294 +++ main/branches/prefix/pym/portage/util.py 2009-08-05 18:10:06 UTC (rev 13922)
295 @@ -57,6 +57,9 @@
296 if fd is None:
297 fd = sys.stderr
298 if noiselevel <= noiselimit:
299 + if sys.hexversion < 0x3000000 and isinstance(mystr, unicode):
300 + # avoid potential UnicodeEncodeError
301 + mystr = mystr.encode('utf_8', 'replace')
302 fd.write(mystr)
303 fd.flush()
304
305
306 Modified: main/branches/prefix/subst-install.in
307 ===================================================================
308 --- main/branches/prefix/subst-install.in 2009-08-05 18:07:45 UTC (rev 13921)
309 +++ main/branches/prefix/subst-install.in 2009-08-05 18:10:06 UTC (rev 13922)
310 @@ -4,15 +4,17 @@
311 prefix="@prefix@"
312 exec_prefix="@exec_prefix@"
313
314 -# for bug #279550 we have to do some nasty trick to make sure that sed
315 +# For bug #279550 we have to do some nasty trick to make sure that sed
316 # doesn't strip the backslash in the replacement value (because it can
317 -# be a backreference) and hence escape those.
318 +# be a backreference) and hence escape those. Eventually in strings we
319 +# need to escape the backslash too, such that the single backslash
320 +# doesn't get lost when considered an invalid escape
321 rootuser="@rootuser@"
322 portagegroup="@portagegroup@"
323 portageuser="@portageuser@"
324 rootuser=${rootuser//\\/\\\\}
325 -portagegroup=${portagegroup//\\/\\\\}
326 -portageuser=${portageuser//\\/\\\\}
327 +portagegroup=${portagegroup//\\/\\\\\\\\}
328 +portageuser=${portageuser//\\/\\\\\\\\}
329
330 # there are many ways to do this all dynamic, but we only care for raw
331 # speed here, so let configure fill in this list and be done with it