summaryrefslogtreecommitdiff
path: root/pyparsing.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2018-09-30 23:21:01 -0500
committerptmcg <ptmcg@austin.rr.com>2018-09-30 23:21:01 -0500
commitc2842b1cae58c09c58110159c91ff06c1a22400b (patch)
treedf263fc96fb7b983c84824be5895dea2f2415d3e /pyparsing.py
parentd5e471b87f2c9f0450ed9dc4895a0366ee81d74f (diff)
downloadpyparsing-git-c2842b1cae58c09c58110159c91ff06c1a22400b.tar.gz
Issue #4 - add special handling for IndexError exceptions raised in user parse actions
Diffstat (limited to 'pyparsing.py')
-rw-r--r--pyparsing.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/pyparsing.py b/pyparsing.py
index 3ea7660..1df31c3 100644
--- a/pyparsing.py
+++ b/pyparsing.py
@@ -74,8 +74,8 @@ classes inherit from. Use the docstrings for examples of how to:
- find more useful common expressions in the L{pyparsing_common} namespace class
"""
-__version__ = "2.2.2"
-__versionTime__ = "29 Sep 2018 15:58 UTC"
+__version__ = "2.3.0"
+__versionTime__ = "01 Oct 2018 04:14 UTC"
__author__ = "Paul McGuire <ptmcg@users.sourceforge.net>"
import string
@@ -1412,7 +1412,13 @@ class ParserElement(object):
if debugging:
try:
for fn in self.parseAction:
- tokens = fn( instring, tokensStart, retTokens )
+ try:
+ tokens = fn( instring, tokensStart, retTokens )
+ except IndexError as parse_action_exc:
+ exc = ParseException("exception raised in parse action")
+ exc.__cause__ = parse_action_exc
+ raise exc
+
if tokens is not None:
retTokens = ParseResults( tokens,
self.resultsName,
@@ -1425,7 +1431,13 @@ class ParserElement(object):
raise
else:
for fn in self.parseAction:
- tokens = fn( instring, tokensStart, retTokens )
+ try:
+ tokens = fn( instring, tokensStart, retTokens )
+ except IndexError as parse_action_exc:
+ exc = ParseException("exception raised in parse action")
+ exc.__cause__ = parse_action_exc
+ raise exc
+
if tokens is not None:
retTokens = ParseResults( tokens,
self.resultsName,