Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Subclasses ofExceptionGroup can wrapBaseExceptions #99553

Closed
Labels
3.11only security fixes3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@Zac-HD

Description

@Zac-HD
classMyEG(ExceptionGroup):"""Holds BaseExceptions without itself being a BaseException."""oops=MyEG("oops", [KeyboardInterrupt()])assertisinstance(oops,Exception)assertnotisinstance(oops.exceptions[0],Exception)

I believe that this is a bug tracing to the period whenPEP-654 did not intend(Base)ExceptionGroup to be usable as a parent class; and I think a sufficient fix would be to replace the type-equality check with an isinstance check in:

if (cls==PyExc_ExceptionGroup) {
if (nested_base_exceptions) {
PyErr_SetString(PyExc_TypeError,
"Cannot nest BaseExceptions in an ExceptionGroup");
gotoerror;

cc@iritkatriel; raised viaagronholm/exceptiongroup#40 (comment)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.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


      [8]ページ先頭

      ©2009-2025 Movatter.jp