Menu

#99 Bug Using ZeroOrMore and And

v1.0 (example)
closed-fixed
nobody
None
1
2018-04-01
2016-09-27
Ethan
No

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.

Discussion

  • Paul McGuire

    Paul McGuire - 2016-09-28
    • status: open --> pending-fixed
    • Priority: 5 --> 1
     
  • Paul McGuire

    Paul McGuire - 2016-09-28

    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.

     
  • Ethan

    Ethan - 2016-09-28

    Thanks!

     
  • Paul McGuire

    Paul McGuire - 2018-04-01
    • status: pending-fixed --> closed-fixed
     
  • Paul McGuire

    Paul McGuire - 2018-04-01

    Fixed October, 2016 in 2.1.10 release

     

Log in to post a comment.