Skip to content

Suspected PyErr_Fetch() behavior change #102594

Closed
@rwgk

Description

@rwgk

Bug report

While testing pybind11 with Python 3.12alpha6 I ran into what looks like a PyErr_Fetch() behavior change. I also tried with the main branch @ c6858d1.

I think the issue reduces to:

The special twist is that the exception type involved raises a ValueError in its __init__:

For easy reference the same code copy-pasted here:

class FlakyException(Exception):
    def __init__(self, failure_point):
        if failure_point == "failure_point_init":
            raise ValueError("triggered_failure_point_init")
        self.failure_point = failure_point
  • Up to and including 3.12alpha3: PyErr_Fetch() produces the FlakyException type (this here).

  • With 3.12alpha6: PyErr_Fetch() produces the ValueError type instead.

Additional detail:

Up to and including 3.12alpha3: only PyErr_NormalizeException() hits the ValueError in FlakyException._init__, but not PyErr_Fetch().

Your environment

  • CPython versions tested on: 3.12alpha6, main branch @ c6858d1
  • Operating system and architecture: Debian 5.19.11 clang14, ubuntu22 gcc11

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions