Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] use_reduce: support non-string token_class (bug 541198)
Date: Tue, 24 Feb 2015 15:49:08
Message-Id: 20150224074900.5da157a7.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] use_reduce: support non-string token_class (bug 541198) by Zac Medico
1 On Mon, 23 Feb 2015 21:35:38 -0800
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Do not assume that token_class returns a basestring.
5 >
6 > X-Gentoo-Bug: 541198
7 > X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=541198
8 > ---
9 > pym/portage/dep/__init__.py | 6 ++++--
10 > 1 file changed, 4 insertions(+), 2 deletions(-)
11 >
12 > diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
13 > index e2e416c..a8c748d 100644
14 > --- a/pym/portage/dep/__init__.py
15 > +++ b/pym/portage/dep/__init__.py
16 > @@ -558,7 +558,8 @@ def use_reduce(depstr, uselist=[], masklist=[],
17 > matchall=False, excludeall=[], i stack[level].extend(l)
18 > continue
19 >
20 > - if stack[level]:
21 > + if stack[level] and
22 > isinstance(stack[level][-1],
23 > + basestring):
24 > if stack[level][-1] == "||"
25 > and not l: #Optimize: || ( ) -> .
26 > stack[level].pop()
27 > @@ -583,7 +584,8 @@ def use_reduce(depstr, uselist=[], masklist=[],
28 > matchall=False, excludeall=[], i #ends in a non-operator. This is
29 > almost equivalent to stack[level][-1]=="||", #expect that it skips
30 > empty levels. while k>=0:
31 > - if stack[k]:
32 > + if stack[k] and
33 > isinstance(stack[k][-1],
34 > + basestring):
35 > if
36 > stack[k][-1] == "||": return k
37 > elif
38 > stack[k][-1][-1] != "?":
39
40
41
42 That was fast. I didn't think you were even online last
43 night ;) I was going to look at it closer this morning, figured it
44 would be something like this to fix.
45
46 LGTM, merge please
47 --
48 Brian Dolbec <dolsen>