Bug Using ZeroOrMore and And
Brought to you by:
ptmcg
I had some issues upgrading pyparsing from 2.1.7 to 2.1.8 using a combination of ZeroOrMore and And. I put together a dummy test case to show the issue.
from pyparsing import Keyword
from pyparsing import ZeroOrMore
def test_build(s, loc, toks):
for i in toks.tests:
print i
stmt = Keyword('test')
statements = ZeroOrMore(stmt)
test_and = ((Keyword('other').suppress() + statements.setResultsName('tests'))
.setParseAction(test_build))
test_and.parseString('other test test')
I would expect this to print out the following:
test
test
That is what get's printed out in 2.1.7. In 2.1.8, the following gets printed out
t
e
s
t
Instead of a list of statements passed into test_build(), it only passes in the first statement and not as a list.
Thanks for reporting this, this is a pretty serious issue! Looks like it goes back to when I refactored OneOrMore and ZeroOrMore. I've checked in a fix to SVN, will release in 2.1.10 in the next day or so.
Thanks!
Fixed October, 2016 in 2.1.10 release