Skip to content

Cannot pickle cyclic ExceptionGroup #137889

@dcolascione

Description

@dcolascione

Bug report

Bug description:

Pickling an exception group with a cycle, like so...

import pickle
inner = Exception("Inner")
outer = ExceptionGroup("outer", [inner])
outer.exceptions[0].foo = outer  
pickle.loads(pickle.dumps(outer))

...produces...

Traceback (most recent call last):
  File "<stdin>", line 5, in <module>
ValueError: second argument (exceptions) must be a non-empty sequence

Maybe BaseExceptionGroup needs a custom reducer that allows for two-phase initialization.

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Metadata

Metadata

Labels

stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions