pyparsing / pyparsing

Python library for creating PEG parsers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regression when using OneOrMore with nestedExpr

tobias-urdin opened this issue · comments

Hello,

We tried upgrading from 3.0.9 to 3.1.0 and noticed the following regression in that the error message changed, is this intended? Thanks!

import pyparsing

v = '(metroc foo bar'

try:
    v = pyparsing.OneOrMore(
            pyparsing.nestedExpr()).parseString(v).asList()[0]
except pyparsing.ParseException as e:
    print(str(e))
(env1) tobias.urdin@MacBook-Pro-TU reprod % pip install pyparsing==3.0.9
Collecting pyparsing==3.0.9
  Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB)
Installing collected packages: pyparsing
Successfully installed pyparsing-3.0.9

(env1) tobias.urdin@MacBook-Pro-TU reprod % python3 test.py 
Expected ')', found end of text  (at char 15), (line:1, col:16)

(env1) tobias.urdin@MacBook-Pro-TU reprod % pip install pyparsing==3.1.0
Collecting pyparsing==3.1.0
  Using cached pyparsing-3.1.0-py3-none-any.whl (102 kB)
Installing collected packages: pyparsing
  Attempting uninstall: pyparsing
    Found existing installation: pyparsing 3.0.9
    Uninstalling pyparsing-3.0.9:
      Successfully uninstalled pyparsing-3.0.9
Successfully installed pyparsing-3.1.0

(env1) tobias.urdin@MacBook-Pro-TU reprod % python3 test.py             
Expected nested () expression, found end of text  (at char 15), (line:1, col:16)

Thanks for submitting this issue. I made some updates in the recent 3.1.1 release around the changes in error messages, but those changes did not address this issue. I agree that the previous error message is clearer and more helpful. I'll try to get a 3.1.2 out with a fix, but it will probably not be for a few weeks.

thanks! :)

Hello @ptmcg 👋 Sorry for the bump – is there any plan to release a new 3.1.2 with a fix for this anytime soon or should we adapt to the new error message instead?

Thanks again for your patience. I will look at this by the weekend at the latest.

Hi, I was looking at this issue a little bit. I wanted to fix it, so that gnocchi can unpin pyparsing. I am unsure what is the correct way to change that error message, but at least I found what change caused this error message to change. Maybe it'll help with fixing the issue. Using the tobias' test code, the pyparsing falls into the except there and rewrites the old "Expected ')' ..." error message to "Expected nested () ...".

4cd691f#diff-651b49e05968bd7f42614f05b7e9d94b30f52db27eb692ce20ef87e9799c624fR4449-R4453

Thanks for the research - looking at this this evening.