Content-Length: 287383 | pFad | https://github.com/python/cpython/issues/98458

50 Unittest: self-referencing explicit exception cause results in infinite loop · Issue #98458 · python/cpython · GitHub
Skip to content

Unittest: self-referencing explicit exception cause results in infinite loop #98458

@AlexTate

Description

@AlexTate

Bug report

If an exception is raised with a self-referencing __cause__ or __context__ then TestResult._clean_tracebacks() in result.py enters an infinite loop.

Minimal example 1:

try:
    raise Exception()
except Exception as e:
    raise e from e

Minimal example 2:

try:
    e = Exception()
    raise e from e
except Exception as e:
    raise e

Identified Cause

Self-references are not checked while unwinding the chained exception on line 216 of result.py

Your environment

  • CPython versions tested on: 3.9, 3.10
  • Operating system and architecture: macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/98458

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy