pyparsing 3.2.0 #575
ptmcg
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Version 3.2.0 - October, 2024
Discontinued support for Python 3.6, 3.7, and 3.8. Adopted new Python features from Python versions 3.7-3.9:
typingmodule (e.g.,list[str]vsList[str]).OrderedDict).pdb.set_trace()call inParserElement.set_break()tobreakpoint().typing.NamedTupletodataclasses.dataclassin railroad diagramming code.from __future__ import annotationsto clean up some type annotations. (with assistance from ISyncWithFoo, issue Changes towards 3.2.0 #535, thanks for the help!)POSSIBLE BREAKING CHANGES
The following bugfixes may result in subtle changes in the results returned or exceptions raised by pyparsing.
Fixed code in
ParseElementEnhancesubclasses that replaced detailed exception messages raised in contained expressions with a less-specific and less-informative generic exception message and location.If your code has conditional logic based on the message content in raised
ParseExceptions, this bugfix may require changes in your code.Fixed bug in
transform_string()where whitespace in the input string was not properly preserved in the output string.If your code uses
transform_string, this bugfix may require changes in your code.Fixed bug where an
IndexErrorraised in a parse action was incorrectly handled as anIndexErrorraised as part of theParserElementparsing methods, and reraised as aParseException. Now anIndexErrorthat raises inside a parse action will properly propagate out as anIndexError. (IssueIndexErrors are handled differently than other exceptions #573, reported by August Karlstedt, thanks!)If your code raises
IndexErrors in parse actions, this bugfix may require changes in your code.FIXES AND NEW FEATURES
Added type annotations to remainder of
pyparsingpackage, and addedmypyrun totox.ini, so that type annotations are now run as part of pyparsing's CI. Addresses Issue Type checking as part of the CI pipeline #373, raised by Iwan Aucamp, thanks!Exception message format can now be customized, by overriding
ParseBaseException.format_message:(PR Add found string as property #571 submitted by Odysseyas Krystalakos, nice work!)
run_testsnow detects if an exception is raised in a parse action, and will report it with an enhanced error message, with the exception type, string, and parse action name.QuotedStringnow handles translation of escaped integer, hex, octal, and Unicode sequences to their corresponding characters.Fixed the displayed output of
Regexterms to deduplicate repeated backslashes, for easier reading in debugging, printing, and railroad diagrams.Fixed (or at least reduced) elusive bug when generating railroad diagrams, where some diagram elements were just empty blocks. Fix submitted by RoDuth, thanks a ton!
Fixed railroad diagrams that get generated with a parser containing a Regex element defined using a verbose pattern - the pattern gets flattened and comments removed before creating the corresponding diagram element.
Defined a more performant regular expression used internally by
common_html_entity.Regexinstances can now be created using a callable that takes no arguments and just returns a string or a compiled regular expression, so that creating complex regular expression patterns can be deferred until they are actually used for the first time in the parser.Added optional
flattenBoolean argument toParseResults.as_list(), to return the parsed values in a flattened list.Added
indentandbase_1arguments topyparsing.testing.with_line_numbers. When usingwith_line_numbersinside a parse action, setbase_1=False, since the reportedlocvalue is 0-based.indentcan be a leading string (typically of spaces or tabs) to indent the numbered string passed towith_line_numbers. Added while working on set_parse_action handler receives seemingly erroneous loc argument #557, reported by Bernd Wechner.NEW/ENHANCED EXAMPLES
Added query syntax to
mongodb_query_expression.pywith:a[0]style array referencingAdded
lox_parser.pyexample, a parser for the Lox language used as a tutorial in Robert Nystrom's "Crafting Interpreters" (http://craftinginterpreters.com/). With helpful corrections from RoDuth.Added
complex_chemical_formulas.pyexample, to add parsing capability for formulas such as "3(C₆H₅OH)₂".Updated
tag_emitter.pyto use newTagclass, introduced in pyparsing 3.1.3.This discussion was created from the release pyparsing 3.2.0.
Beta Was this translation helpful? Give feedback.
All reactions