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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy