Commit c6172d12 authored by Andreas Jung's avatar Andreas Jung

Fixed (hopefully) a longtime outstanding problem in parens():
- the former regex never matched any parentheses
- the parens() used old regex module API although 're' module was used
parent fe555b16
......@@ -91,7 +91,7 @@ undo information so that objects can be unindexed when the old value
is no longer known.
"""
__version__ = '$Revision: 1.5 $'[11:-2]
__version__ = '$Revision: 1.6 $'[11:-2]
import string, re
......@@ -742,13 +742,16 @@ def parse2(q, default_operator,
return q
def parens(s, parens_re=re.compile(r'(\|)').search):
def parens(s, parens_re=re.compile('[\(\)]').search):
index = open_index = paren_count = 0
while 1:
index = parens_re(s, index)
if index is None : break
mo = parens_re(s, index)
if mo is None : break
index = mo.start(0)
if s[index] == '(':
paren_count = paren_count + 1
......@@ -767,7 +770,6 @@ def parens(s, parens_re=re.compile(r'(\|)').search):
raise QueryError, "Mismatched parentheses"
def quotes(s, ws=(string.whitespace,)):
# split up quoted regions
splitted = re.split( '[%s]*\"[%s]*' % (ws * 2),s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment