[New-bugs-announce] [issue45033] Calls to PyErr_PrintEx in destructors cause calling async functions to incorrectly return None

Zac Bentley report at bugs.python.org
Fri Aug 27 19:56:25 EDT 2021


New submission from Zac Bentley <zbbentley at gmail.com>:

If an object's destructor contains native code which calls PyErr_PrintEx, and that object's refcount drops to zero as the result of an async function returning, the async function incorrectly returns None.

I first identified this behavior while using Boost-python. A more detailed description, and steps to reproduce, are in the issue report I filed on that library: https://github.com/boostorg/python/issues/374

I'm not very familiar with interpreter internals, so it is possible that this is expected behavior. However, it does seem like at least a leaky abstraction between the mechanics of async calls (which use exception based control flow internally) and the PyErr_PrintEx function, which is typically invoked by callers interested in finding out about errors that they caused, not errors that are both caused elsewhere and whose propagation is important to preserving call stack state.

----------
components: C API, Interpreter Core, asyncio
messages: 400448
nosy: asvetlov, yselivanov, zbentley
priority: normal
severity: normal
status: open
title: Calls to PyErr_PrintEx in destructors cause calling async functions to incorrectly return None
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45033>
_______________________________________


More information about the New-bugs-announce mailing list