1 |
On Mon, 2019-10-21 at 02:10 -0700, Zac Medico wrote: |
2 |
> On 10/21/19 1:43 AM, Michał Górny wrote: |
3 |
> > Use real os.walk() when getting filenames for FlatLayout. Unlike |
4 |
> > the wrapped Portage module, it return str output for str path parameter, |
5 |
> > so we don't have to recode it back and forth. |
6 |
> > |
7 |
> > Signed-off-by: Michał Górny <mgorny@g.o> |
8 |
> > --- |
9 |
> > lib/portage/package/ebuild/fetch.py | 3 ++- |
10 |
> > 1 file changed, 2 insertions(+), 1 deletion(-) |
11 |
> > |
12 |
> > diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py |
13 |
> > index cedf12b19..be277f1a3 100644 |
14 |
> > --- a/lib/portage/package/ebuild/fetch.py |
15 |
> > +++ b/lib/portage/package/ebuild/fetch.py |
16 |
> > @@ -11,6 +11,7 @@ import io |
17 |
> > import itertools |
18 |
> > import json |
19 |
> > import logging |
20 |
> > +import os as real_os |
21 |
> > import random |
22 |
> > import re |
23 |
> > import stat |
24 |
> > @@ -270,7 +271,7 @@ class FlatLayout(object): |
25 |
> > return filename |
26 |
> > |
27 |
> > def get_filenames(self, distdir): |
28 |
> > - for dirpath, dirnames, filenames in os.walk(distdir, |
29 |
> > + for dirpath, dirnames, filenames in real_os.walk(distdir, |
30 |
> > onerror=_raise_exc): |
31 |
> > return iter(filenames) |
32 |
> > |
33 |
> > |
34 |
> |
35 |
> The real_os.walk will trigger UnicodeEncodeError if distdir can't be |
36 |
> encoded with sys.getfilesystemencoding(). It's an edge case, but |
37 |
> generally I prefer to handle it. |
38 |
> |
39 |
> We can continue to use portage.os for the os.walk call, and turn |
40 |
> get_filenames into a generator method like this: |
41 |
> |
42 |
> for filename in filenames: |
43 |
> try: |
44 |
> yield portage._unicode_decode(filename, errors='strict') |
45 |
> except UnicodeDecodeError: |
46 |
> # Ignore it. Distfiles names must have valid UTF8 encoding. |
47 |
> pass |
48 |
|
49 |
Since you've already written it, could you commit it? I don't wish to |
50 |
have my name on the implicit module overrides hackery I don't approve |
51 |
of. |
52 |
|
53 |
-- |
54 |
Best regards, |
55 |
Michał Górny |