This is against portage version "2.0.46-r2" To reproduce: $ python Python 2.2.2 (#1, Dec 9 2002, 15:11:45) [GCC 3.2.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import portage >>> portage.tokenize("top1 top2 (sub1 sub2 (subsub1 subsub2) sub3) top3") ['top1', 'top2', ['sub1', 'sub2', ['subsub1', 'subsub2'], 'sub3', 'top3']] Note that the token 'top3' ends up on the same list as sub1, sub2, and sub3; I would expect it to be put on the same list as top1 and top2. An obvious fix is to use a stack, instead of the single variable called prevlist to keep track of "the previous lists." I am attaching a diff that does that. With the diff installed, the following output is produced: $ python Python 2.2.2 (#1, Dec 9 2002, 15:11:45) [GCC 3.2.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import portage >>> portage.tokenize("top1 top2 (sub1 sub2 (subsub1 subsub2) sub3) top3") ['top1', 'top2', ['sub1', 'sub2', ['subsub1', 'subsub2'], 'sub3'], 'top3'] I dunno if this matters to anyone. FWIW, I installed the change on my system, re-generated both portage.pyc and portage.pyo, and my computer hasn't blown up yet. (But I'll keep you posted, in case it does ;-).
Created attachment 6628 [details, diff] A suggested patch against portage.py
Incorporated and testing. Looks good. Thanks.