Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 12507 - A possible buglet in portage.tokenize(); portage version: "2.0.46-r2"
Summary: A possible buglet in portage.tokenize(); portage version: "2.0.46-r2"
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Nicholas Jones (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-21 01:40 UTC by Evgeny Roubinchtein
Modified: 2011-10-30 22:20 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
A suggested patch against portage.py (portage.py.diff,789 bytes, patch)
2002-12-21 01:41 UTC, Evgeny Roubinchtein
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Evgeny Roubinchtein 2002-12-21 01:40:19 UTC
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 ;-).
Comment 1 Evgeny Roubinchtein 2002-12-21 01:41:41 UTC
Created attachment 6628 [details, diff]
A suggested patch against portage.py
Comment 2 Nicholas Jones (RETIRED) gentoo-dev 2002-12-24 03:57:28 UTC
Incorporated and testing. Looks good.
Thanks.