Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 76372 - 1) Document default usage 2) add Try Catch block around regex.append()
Summary: 1) Document default usage 2) add Try Catch block around regex.append()
Status: RESOLVED UPSTREAM
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords:
: 76373 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-01-01 20:24 UTC by Alec Warner
Modified: 2005-01-01 20:46 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alec Warner (RETIRED) archtester gentoo-dev Security 2005-01-01 20:24:42 UTC
2)for pattern in patterns:
    if pattern == "*":
        pattern = ".*"
    else:
        pattern = re.sub("\+\+", "\+\+", pattern)
    regexlist.append([re.compile(pattern, re.IGNORECASE), pattern, "", 0])
The call to append should be in a try block, because the re.compile can fail.
1) Could we add a CLI option for no regex?  esearch libstdc++ works great except it's not a regex, and is escaped in the output
<snip>
spider gcc # esearch libstdc++
[ Results for search key : libstdc\+\+ ]
</snip>

Reproducible: Always
Steps to Reproduce:
1. To crash, simply emerge +
2.
3.

Actual Results:  
spider esearch # esearch +
Traceback (most recent call last):
  File "/usr/bin/esearch", line 180, in ?
    regexlist.append([re.compile(pattern, re.IGNORECASE), pattern, "", 0])
  File "/usr/lib/python2.3/sre.py", line 179, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.3/sre.py", line 230, in _compile
    raise error, v # invalid expression
sre_constants.error: nothing to repeat


Expected Results:  
Caught the exception and told the user they are stupid and that '+' is not a 
valid regex

I was unaware orginally that this used regex by default, always using it as just 
a string-matching search tool ;)  Giving it non-regex input really pisses it 
off, and at times regex's just aren't needed.  Sometimes I know what package I 
want to look up and it's just easier to query the status of the package ( 
masked/installed/etc ) using esearch.  Especially in cases where package names 
aren't valid regex's there could be a problem where you CAN'T look up a package 
because it's name is not a valid regex.
Comment 1 Alec Warner (RETIRED) archtester gentoo-dev Security 2005-01-01 20:45:49 UTC
*** Bug 76373 has been marked as a duplicate of this bug. ***
Comment 2 Alec Warner (RETIRED) archtester gentoo-dev Security 2005-01-01 20:46:25 UTC
E-mailed him the request instead, non-gentoo package.