1 |
Author: zmedico |
2 |
Date: 2009-08-06 05:35:14 +0000 (Thu, 06 Aug 2009) |
3 |
New Revision: 13926 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/__init__.py |
7 |
main/trunk/pym/portage/cache/ebuild_xattr.py |
8 |
main/trunk/pym/portage/dbapi/vartree.py |
9 |
main/trunk/pym/portage/env/loaders.py |
10 |
main/trunk/pym/portage/manifest.py |
11 |
main/trunk/pym/portage/sets/files.py |
12 |
main/trunk/pym/portage/update.py |
13 |
main/trunk/pym/portage/util.py |
14 |
Log: |
15 |
Do not pass unicode strings into os.walk calls, since it can cause |
16 |
internal os.path.join calls to raise UnicodeDecodeError. |
17 |
|
18 |
|
19 |
Modified: main/trunk/pym/portage/__init__.py |
20 |
=================================================================== |
21 |
--- main/trunk/pym/portage/__init__.py 2009-08-06 01:05:43 UTC (rev 13925) |
22 |
+++ main/trunk/pym/portage/__init__.py 2009-08-06 05:35:14 UTC (rev 13926) |
23 |
@@ -4901,6 +4901,11 @@ |
24 |
""" epatch will just grab all the patches out of a directory, so we have to |
25 |
make sure there aren't any foreign files that it might grab.""" |
26 |
filesdir = os.path.join(pkgdir, "files") |
27 |
+ if isinstance(filesdir, unicode): |
28 |
+ # Avoid UnicodeDecodeError raised from |
29 |
+ # os.path.join when called by os.walk. |
30 |
+ filesdir = filesdir.encode('utf_8', 'replace') |
31 |
+ |
32 |
for parent, dirs, files in os.walk(filesdir): |
33 |
for d in dirs: |
34 |
if d.startswith(".") or d == "CVS": |
35 |
@@ -5158,6 +5163,12 @@ |
36 |
os.system("chflags -R nosunlnk,nouunlnk %s 2>/dev/null" % \ |
37 |
(_shell_quote(mysettings["D"]),)) |
38 |
|
39 |
+ destdir = mysettings["D"] |
40 |
+ if isinstance(destdir, unicode): |
41 |
+ # Avoid UnicodeDecodeError raised from |
42 |
+ # os.path.join when called by os.walk. |
43 |
+ destdir = destdir.encode('utf_8', 'replace') |
44 |
+ |
45 |
for parent, dirs, files in os.walk(mysettings["D"]): |
46 |
for fname in chain(dirs, files): |
47 |
fpath = os.path.join(parent, fname) |
48 |
|
49 |
Modified: main/trunk/pym/portage/cache/ebuild_xattr.py |
50 |
=================================================================== |
51 |
--- main/trunk/pym/portage/cache/ebuild_xattr.py 2009-08-06 01:05:43 UTC (rev 13925) |
52 |
+++ main/trunk/pym/portage/cache/ebuild_xattr.py 2009-08-06 05:35:14 UTC (rev 13926) |
53 |
@@ -153,7 +153,14 @@ |
54 |
return os.path.exists(self.__get_path(cpv)) |
55 |
|
56 |
def __iter__(self): |
57 |
- for root,dirs,files in os.walk(self.portdir): |
58 |
+ |
59 |
+ portdir = self.portdir |
60 |
+ if isinstance(portdir, unicode): |
61 |
+ # Avoid UnicodeDecodeError raised from |
62 |
+ # os.path.join when called by os.walk. |
63 |
+ portdir = portdir.encode('utf_8', 'replace') |
64 |
+ |
65 |
+ for root, dirs, files in os.walk(portdir): |
66 |
for file in files: |
67 |
if file[-7:] == '.ebuild': |
68 |
cat = os.path.basename(os.path.dirname(root)) |
69 |
|
70 |
Modified: main/trunk/pym/portage/dbapi/vartree.py |
71 |
=================================================================== |
72 |
--- main/trunk/pym/portage/dbapi/vartree.py 2009-08-06 01:05:43 UTC (rev 13925) |
73 |
+++ main/trunk/pym/portage/dbapi/vartree.py 2009-08-06 05:35:14 UTC (rev 13926) |
74 |
@@ -3221,6 +3221,12 @@ |
75 |
myfilelist = [] |
76 |
mylinklist = [] |
77 |
paths_with_newlines = [] |
78 |
+ |
79 |
+ if isinstance(srcroot, unicode): |
80 |
+ # Avoid UnicodeDecodeError raised from |
81 |
+ # os.path.join when called by os.walk. |
82 |
+ srcroot = srcroot.encode('utf_8', 'replace') |
83 |
+ |
84 |
srcroot_len = len(srcroot) |
85 |
def onerror(e): |
86 |
raise |
87 |
|
88 |
Modified: main/trunk/pym/portage/env/loaders.py |
89 |
=================================================================== |
90 |
--- main/trunk/pym/portage/env/loaders.py 2009-08-06 01:05:43 UTC (rev 13925) |
91 |
+++ main/trunk/pym/portage/env/loaders.py 2009-08-06 05:35:14 UTC (rev 13926) |
92 |
@@ -39,6 +39,12 @@ |
93 |
@rtype: list |
94 |
@returns: List of files to process |
95 |
""" |
96 |
+ |
97 |
+ if isinstance(filename, unicode): |
98 |
+ # Avoid UnicodeDecodeError raised from |
99 |
+ # os.path.join when called by os.walk. |
100 |
+ filename = filename.encode('utf_8', 'replace') |
101 |
+ |
102 |
try: |
103 |
st = os.stat(filename) |
104 |
except OSError: |
105 |
|
106 |
Modified: main/trunk/pym/portage/manifest.py |
107 |
=================================================================== |
108 |
--- main/trunk/pym/portage/manifest.py 2009-08-06 01:05:43 UTC (rev 13925) |
109 |
+++ main/trunk/pym/portage/manifest.py 2009-08-06 05:35:14 UTC (rev 13926) |
110 |
@@ -306,7 +306,14 @@ |
111 |
cpvlist = [] |
112 |
pn = os.path.basename(self.pkgdir.rstrip(os.path.sep)) |
113 |
cat = self._pkgdir_category() |
114 |
- for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(self.pkgdir): |
115 |
+ |
116 |
+ pkgdir = self.pkgdir |
117 |
+ if isinstance(pkgdir, unicode): |
118 |
+ # Avoid UnicodeDecodeError raised from |
119 |
+ # os.path.join when called by os.walk. |
120 |
+ pkgdir = pkgdir.encode('utf_8', 'replace') |
121 |
+ |
122 |
+ for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir): |
123 |
break |
124 |
for f in pkgdir_files: |
125 |
if f[:1] == ".": |
126 |
@@ -334,8 +341,15 @@ |
127 |
continue |
128 |
self.fhashdict[mytype][f] = perform_multiple_checksums(self.pkgdir+f, self.hashes) |
129 |
recursive_files = [] |
130 |
- cut_len = len(os.path.join(self.pkgdir, "files") + os.sep) |
131 |
- for parentdir, dirs, files in os.walk(os.path.join(self.pkgdir, "files")): |
132 |
+ |
133 |
+ pkgdir = self.pkgdir |
134 |
+ if isinstance(pkgdir, unicode): |
135 |
+ # Avoid UnicodeDecodeError raised from |
136 |
+ # os.path.join when called by os.walk. |
137 |
+ pkgdir = pkgdir.encode('utf_8', 'replace') |
138 |
+ |
139 |
+ cut_len = len(os.path.join(pkgdir, "files") + os.sep) |
140 |
+ for parentdir, dirs, files in os.walk(os.path.join(pkgdir, "files")): |
141 |
for f in files: |
142 |
full_path = os.path.join(parentdir, f) |
143 |
recursive_files.append(full_path[cut_len:]) |
144 |
|
145 |
Modified: main/trunk/pym/portage/sets/files.py |
146 |
=================================================================== |
147 |
--- main/trunk/pym/portage/sets/files.py 2009-08-06 01:05:43 UTC (rev 13925) |
148 |
+++ main/trunk/pym/portage/sets/files.py 2009-08-06 05:35:14 UTC (rev 13926) |
149 |
@@ -125,9 +125,22 @@ |
150 |
directory = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], directory) |
151 |
except KeyError: |
152 |
raise SetConfigError(_("Could not find repository '%s'") % match.groupdict()["reponame"]) |
153 |
+ |
154 |
+ if isinstance(directory, unicode): |
155 |
+ # Avoid UnicodeDecodeError raised from |
156 |
+ # os.path.join when called by os.walk. |
157 |
+ directory_unicode = directory |
158 |
+ directory = directory.encode('utf_8', 'replace') |
159 |
+ else: |
160 |
+ directory_unicode = unicode(directory, |
161 |
+ encoding='utf_8', errors='replace') |
162 |
+ |
163 |
if os.path.isdir(directory): |
164 |
directory = normalize_path(directory) |
165 |
for parent, dirs, files in os.walk(directory): |
166 |
+ if not isinstance(parent, unicode): |
167 |
+ parent = unicode(parent, |
168 |
+ encoding='utf_8', errors='replace') |
169 |
for d in dirs[:]: |
170 |
if d[:1] == '.': |
171 |
dirs.remove(d) |
172 |
@@ -140,7 +153,7 @@ |
173 |
if filename.endswith(".metadata"): |
174 |
continue |
175 |
filename = os.path.join(parent, |
176 |
- filename)[1 + len(directory):] |
177 |
+ filename)[1 + len(directory_unicode):] |
178 |
myname = name_pattern.replace("$name", filename) |
179 |
myname = myname.replace("${name}", filename) |
180 |
rValue[myname] = StaticFileSet( |
181 |
|
182 |
Modified: main/trunk/pym/portage/update.py |
183 |
=================================================================== |
184 |
--- main/trunk/pym/portage/update.py 2009-08-06 01:05:43 UTC (rev 13925) |
185 |
+++ main/trunk/pym/portage/update.py 2009-08-06 05:35:14 UTC (rev 13926) |
186 |
@@ -146,6 +146,12 @@ |
187 |
protect - list of paths from CONFIG_PROTECT |
188 |
protect_mask - list of paths from CONFIG_PROTECT_MASK |
189 |
update_iter - list of update commands as returned from parse_updates()""" |
190 |
+ |
191 |
+ if isinstance(config_root, unicode): |
192 |
+ # Avoid UnicodeDecodeError raised from |
193 |
+ # os.path.join when called by os.walk. |
194 |
+ config_root = config_root.encode('utf_8', 'replace') |
195 |
+ |
196 |
config_root = normalize_path(config_root) |
197 |
update_files = {} |
198 |
file_contents = {} |
199 |
|
200 |
Modified: main/trunk/pym/portage/util.py |
201 |
=================================================================== |
202 |
--- main/trunk/pym/portage/util.py 2009-08-06 01:05:43 UTC (rev 13925) |
203 |
+++ main/trunk/pym/portage/util.py 2009-08-06 05:35:14 UTC (rev 13926) |
204 |
@@ -780,6 +780,11 @@ |
205 |
Returns True if all permissions are applied and False if some are left |
206 |
unapplied.""" |
207 |
|
208 |
+ if isinstance(top, unicode): |
209 |
+ # Avoid UnicodeDecodeError raised from |
210 |
+ # os.path.join when called by os.walk. |
211 |
+ top = top.encode('utf_8', 'replace') |
212 |
+ |
213 |
if onerror is None: |
214 |
# Default behavior is to dump errors to stderr so they won't |
215 |
# go unnoticed. Callers can pass in a quiet instance. |