Skip to content

Commit 508750e

Browse files
committed
Convert SyntaxWarnings to ValueError and TypeError exceptions; change diagnostics to an enum, and add enable_diag(), disable_diag() and enable_all_warnings() methods; clean up pyparsing imports in test_unit.py
1 parent af90c6d commit 508750e

File tree

5 files changed

+436
-570
lines changed

5 files changed

+436
-570
lines changed

CHANGES

+19-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ Change Log
44

55
Version 3.0.0b1
66
---------------
7-
- When using setDebug with packrat parsing enabled, packrat cache hits will
8-
now be included in the output, shown with a leading '*'. (Previously, cache
9-
hits and responses were not included in debug output.) For those using custom
10-
debug actions, see the following bullet regarding an optional API change
11-
for those methods.
7+
- API CHANGE
8+
Diagnostic flags have been moved to an enum, pyparsing.Diagnostics, and
9+
they are enabled through module-level methods:
10+
- enable_diag()
11+
- disable_diag()
12+
- enable_all_warnings()
13+
14+
- API CHANGE
15+
Most previous SyntaxWarnings that were warned when using pyparsing
16+
classes incorrectly have been converted to TypeError and ValueError exceptions,
17+
consistent with Python calling conventions. All warnings warned by diagnostic
18+
flags have been converted from SyntaxWarnings to UserWarnings.
1219

1320
- API CHANGE
1421
Added `cache_hit` keyword argument to debug actions. Previously, if packrat
@@ -22,6 +29,12 @@ Version 3.0.0b1
2229
to add this keyword argument, the debug methods will fail silently,
2330
behaving as they did previously.
2431

32+
- When using setDebug with packrat parsing enabled, packrat cache hits will
33+
now be included in the output, shown with a leading '*'. (Previously, cache
34+
hits and responses were not included in debug output.) For those using custom
35+
debug actions, see the following bullet regarding an optional API change
36+
for those methods.
37+
2538
- Fixed traceback trimming, and added ParserElement.verbose_traceback
2639
save/restore to reset_pyparsing_context().
2740

@@ -47,7 +60,7 @@ Version 3.0.0b1
4760
thanks!
4861

4962
- In addition to pyparsing.__version__, there is now also a pyparsing.__version_info__,
50-
following the same structure and names as in sys.version_info.
63+
following the same structure and field names as in sys.version_info.
5164

5265

5366
Version 3.0.0a2 - June, 2020

docs/HowToUsePyparsing.rst

+13-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The parsed tokens are returned in the following form::
7777
['Hello', ',', 'World', '!']
7878
['Bonjour', ',', 'Monde', '!']
7979
['Hola', ',', 'Mundo', '!']
80-
['Gutentag', ',', 'Welt', '!']
80+
['Hallo', ',', 'Welt', '!']
8181

8282

8383
Usage notes
@@ -809,7 +809,7 @@ Exception classes and Troubleshooting
809809
and ``setDebug()``, or test the matching of expression fragments by testing them using
810810
``searchString()`` or ``scanString()``.
811811

812-
- Diagnostics can be enabled using ``pyparsing.enable_diagnostic`` and passing
812+
- Diagnostics can be enabled using ``pyparsing.enable_diag`` and passing
813813
one of the following enum values defined in ``pyparsing.Diagnostics``
814814

815815
- ``warn_multiple_tokens_in_named_alternation`` - flag to enable warnings when a results
@@ -834,6 +834,17 @@ Exception classes and Troubleshooting
834834
- ``enable_debug_on_named_expressions`` - flag to auto-enable debug on all subsequent
835835
calls to ``ParserElement.setName``
836836

837+
All warnings can be enabled by calling ``pyparsing.enable_all_warnings()``.
838+
Sample::
839+
840+
import pyparsing as pp
841+
pp.enable_all_warnings()
842+
843+
fwd = pp.Forward().setResultsName("recursive_expr")
844+
845+
>>> UserWarning: warn_name_set_on_empty_Forward: setting results name 'recursive_expr'
846+
on Forward expression that has no contained expression
847+
837848

838849
Miscellaneous attributes and methods
839850
====================================

0 commit comments

Comments
 (0)