summaryrefslogtreecommitdiff
path: root/pyparsing.py
diff options
context:
space:
mode:
authorptmcg <ptmcg@austin.rr.com>2020-03-07 00:08:34 -0600
committerptmcg <ptmcg@austin.rr.com>2020-03-07 00:08:34 -0600
commit281b031c231663994da14c28025412e778763c32 (patch)
tree3e54cdd28ee4adbf0a5ebe14d08421a7797ee446 /pyparsing.py
parent7daecd9e3d0b39b15c755b00d717857cca68753f (diff)
downloadpyparsing-git-281b031c231663994da14c28025412e778763c32.tar.gz
Py2 exceptions need special checks for presence of __traceback__
Diffstat (limited to 'pyparsing.py')
-rw-r--r--pyparsing.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/pyparsing.py b/pyparsing.py
index 135b6a0..8f30af6 100644
--- a/pyparsing.py
+++ b/pyparsing.py
@@ -1950,7 +1950,8 @@ class ParserElement(object):
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
- exc.__traceback__ = self._trim_traceback(exc.__traceback__)
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
else:
return tokens
@@ -2025,7 +2026,8 @@ class ParserElement(object):
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
- exc.__traceback__ = self._trim_traceback(exc.__traceback__)
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def transformString(self, instring):
@@ -2072,7 +2074,8 @@ class ParserElement(object):
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
- exc.__traceback__ = self._trim_traceback(exc.__traceback__)
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def searchString(self, instring, maxMatches=_MAX_INT):
@@ -2103,7 +2106,8 @@ class ParserElement(object):
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
- exc.__traceback__ = self._trim_traceback(exc.__traceback__)
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def split(self, instring, maxsplit=_MAX_INT, includeSeparators=False):
@@ -2576,7 +2580,8 @@ class ParserElement(object):
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
- exc.__traceback__ = self._trim_traceback(exc.__traceback__)
+ if getattr(exc, '__traceback__', None) is not None:
+ exc.__traceback__ = self._trim_traceback(exc.__traceback__)
raise exc
def __eq__(self, other):