diff options
author | ptmcg <ptmcg@austin.rr.com> | 2019-01-09 17:27:33 -0600 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2019-01-09 17:27:33 -0600 |
commit | 17aeb190d87186e769ddea8752099d841421faab (patch) | |
tree | 204ac99a650c165d8ab10a569193bb5237eb979d /pyparsing.py | |
parent | d626c99b6288afc4708d72f668b45a29d3263d22 (diff) | |
download | pyparsing-git-17aeb190d87186e769ddea8752099d841421faab.tar.gz |
Modify explain() for Py2 compat
Diffstat (limited to 'pyparsing.py')
-rw-r--r-- | pyparsing.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pyparsing.py b/pyparsing.py index d6f016d..fd7c0fa 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -94,7 +94,7 @@ classes inherit from. Use the docstrings for examples of how to: """ __version__ = "2.3.1" -__versionTime__ = "09 Jan 2019 23:17 UTC" +__versionTime__ = "09 Jan 2019 23:26 UTC" __author__ = "Paul McGuire <ptmcg@users.sourceforge.net>" import string @@ -344,7 +344,12 @@ class ParseException(ParseBaseException): ret.append(' ' * (exc.col - 1) + '^') ret.append("{0}: {1}".format(type(exc).__name__, exc)) - callers = inspect.getinnerframes(exc.__traceback__, context=depth) + 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: |