summaryrefslogtreecommitdiff
path: root/pyparsing.py
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 /pyparsing.py
parentb600b54e06a6a99e90634128d37b7edb15cb367f (diff)
downloadpyparsing-git-afddc54054ce3c30c68f60e4b9985bb478908a84.tar.gz
Add note that explain() is only supported under Python 3.
Diffstat (limited to 'pyparsing.py')
-rw-r--r--pyparsing.py12
1 files changed, 4 insertions, 8 deletions
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