mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-132308: prevent TracebackException
swallowing attributes of a falsey Exception
or ExceptionGroup
(GH-132363) (#132725)
gh-132308: prevent `TracebackException` swallowing attributes of a falsey `Exception` or `ExceptionGroup` (GH-132363)
(cherry picked from commit 69cda31261
)
Co-authored-by: Duprat <yduprat@gmail.com>
This commit is contained in:
parent
7998f998b2
commit
dfaa384991
3 changed files with 57 additions and 3 deletions
|
@ -1116,7 +1116,7 @@ class TracebackException:
|
|||
queue = [(self, exc_value)]
|
||||
while queue:
|
||||
te, e = queue.pop()
|
||||
if (e and e.__cause__ is not None
|
||||
if (e is not None and e.__cause__ is not None
|
||||
and id(e.__cause__) not in _seen):
|
||||
cause = TracebackException(
|
||||
type(e.__cause__),
|
||||
|
@ -1137,7 +1137,7 @@ class TracebackException:
|
|||
not e.__suppress_context__)
|
||||
else:
|
||||
need_context = True
|
||||
if (e and e.__context__ is not None
|
||||
if (e is not None and e.__context__ is not None
|
||||
and need_context and id(e.__context__) not in _seen):
|
||||
context = TracebackException(
|
||||
type(e.__context__),
|
||||
|
@ -1152,7 +1152,7 @@ class TracebackException:
|
|||
else:
|
||||
context = None
|
||||
|
||||
if e and isinstance(e, BaseExceptionGroup):
|
||||
if e is not None and isinstance(e, BaseExceptionGroup):
|
||||
exceptions = []
|
||||
for exc in e.exceptions:
|
||||
texc = TracebackException(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue