Skip to content

dict/func/code watchers may call dealloc callback with exception set #102385

Closed
@carljm

Description

@carljm

The docs at https://python.readthedocs.io/en/stable/extending/newtypes.html#finalization-and-de-allocation note that dealloc funcs need to be careful to work correctly in the presence of a pending exception, because deallocation may happen in unwinding while an exception is pending.

func_dealloc, code_dealloc, and dict_dealloc all may call watcher callbacks with a deallocation event. We shouldn't call a user callback with a pending exception set; this could cause all kinds of hard-to-debug issues. We should save/restore the exception around the callback.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions