summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2019-01-09 17:44:55 -0600
committerptmcg <ptmcg@austin.rr.com>2019-01-09 17:44:55 -0600
commitafddc54054ce3c30c68f60e4b9985bb478908a84 (patch)
tree58613ec2167fb3cdfaa11d6568c033aad033a881
parentb600b54e06a6a99e90634128d37b7edb15cb367f (diff)
downloadpyparsing-git-afddc54054ce3c30c68f60e4b9985bb478908a84.tar.gz
Add note that explain() is only supported under Python 3.
-rw-r--r--CHANGES2
-rw-r--r--pyparsing.py12
2 files changed, 6 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index eb13d01..675a284 100644
--- a/CHANGES
+++ b/CHANGES
@@ -42,6 +42,8 @@ Version 2.3.1 - January, 2019
names and parse expressions in the stack trace. This is especially
useful when an exception is raised in a parse action.
+ Note: explain() is only supported under Python 3.
+
- Fix bug in dictOf which could match an empty sequence, making it
infinitely loop if wrapped in a OneOrMore.
diff --git a/pyparsing.py b/pyparsing.py
index fd7c0fa..ab804d5 100644
--- a/pyparsing.py
+++ b/pyparsing.py
@@ -333,6 +333,8 @@ class ParseException(ParseBaseException):
that failed to parse. These representations will be more helpful if you use `setName` to
give identifiable names to your expressions. Otherwise they will use the default string
forms, which may be cryptic to read.
+
+ explain() is only supported under Python 3.
"""
import inspect
@@ -344,15 +346,9 @@ class ParseException(ParseBaseException):
ret.append(' ' * (exc.col - 1) + '^')
ret.append("{0}: {1}".format(type(exc).__name__, exc))
- if hasattr(exc, '__traceback__'):
- exc_tb = exc.__traceback__
- else:
- exc_tb = sys.exc_info()[-1]
- callers = inspect.getinnerframes(exc_tb, context=depth)
-
- seen = set()
-
if depth > 0:
+ callers = inspect.getinnerframes(exc.__traceback__, context=depth)
+ seen = set()
for i, ff in enumerate(callers[-depth:]):
frm = ff.frame