Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Parsing error for Words withsetResultsName (regression in 3.2.4) #618

Closed
Assignees
ptmcg
@mstimberg

Description

@mstimberg

We are usingpyparsing to parse physical equation and parameter definitions. Potentially we are using it wrong, but the following (simplified) version works in 3.2.3, but fails in 3.2.4:

importstringfrompyparsingimportWord,Group,SuppressIDENTIFIER=Word(string.ascii_letters+"_",string.ascii_letters+string.digits+"_").setResultsName("identifier")# very broad definition here, whether this corresponds to a valid unit string will be checked laterUNIT=Word(string.ascii_letters+string.digits+"*/.- ").setResultsName("unit")PARAMETER_EQ=Group(IDENTIFIER+Suppress(":")+UNIT)print(repr(PARAMETER_EQ.parse_string("speed : meter/second")))

In 3.2.3, this prints:

ParseResults([ParseResults(['speed', 'meter/second'], {'identifier': 'speed', 'unit': 'meter/second'})], {})

whereas in 3.2.4, it fails with:

Traceback (most recent call last):  File"/home/mstimberg/scratch/pyparsing_issue.py", line15, in<module>print(repr(PARAMETER_EQ.parse_string("speed : meter/second")))~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/mstimberg/.cache/uv/archive-v0/b2gwMgK-avsJGeZiOPy1f/lib/python3.13/site-packages/pyparsing/core.py", line1306, inparse_string    loc, tokens=self._parse(instring,0)~~~~~~~~~~~^^^^^^^^^^^^^  File"/home/mstimberg/.cache/uv/archive-v0/b2gwMgK-avsJGeZiOPy1f/lib/python3.13/site-packages/pyparsing/core.py", line933, in_parseNoCache    loc, tokens=self.parseImpl(instring, pre_loc, do_actions)~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/mstimberg/.cache/uv/archive-v0/b2gwMgK-avsJGeZiOPy1f/lib/python3.13/site-packages/pyparsing/core.py", line5034, inparseImplreturnself.expr._parse(instring, loc, do_actions,callPreParse=False)~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/mstimberg/.cache/uv/archive-v0/b2gwMgK-avsJGeZiOPy1f/lib/python3.13/site-packages/pyparsing/core.py", line933, in_parseNoCache    loc, tokens=self.parseImpl(instring, pre_loc, do_actions)~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/mstimberg/.cache/uv/archive-v0/b2gwMgK-avsJGeZiOPy1f/lib/python3.13/site-packages/pyparsing/core.py", line4513, inparseImpl    loc, exprtokens= e._parse(instring, loc, do_actions)~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/mstimberg/.cache/uv/archive-v0/b2gwMgK-avsJGeZiOPy1f/lib/python3.13/site-packages/pyparsing/core.py", line937, in_parseNoCache    loc, tokens=self.parseImpl(instring, pre_loc, do_actions)~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/home/mstimberg/.cache/uv/archive-v0/b2gwMgK-avsJGeZiOPy1f/lib/python3.13/site-packages/pyparsing/core.py", line3290, inparseImpl_regex    result=self.re_match(instring, loc)^^^^^^^^^^^^^AttributeError:'Word' object has no attribute 're_match'

From reading the changelog, it might be related to the fix for#612?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp