bpo-39947: revert incorrect change to a comment by iritkatriel · Pull Request #26788 · python/cpython

Until Python 3.8, Py_TRASHCAN_BEGIN_CONDITION emitted a call to the _PyTrash_thread_deposit_object() function. So any C extension built with the stable ABI would call _PyTrash_thread_deposit_object() function at the ABI level. If you modify _PyTrash_thread_deposit_object() to make it a no-op function, it will break these C extensions.

But. The Py_TRASHCAN_BEGIN_CONDITION API was not usable with the limited C API (on Python 3.8 and older) since it accessed to PyThreadState members like _tstate->trash_delete_nesting, whereas PyThreadState structure is opaque in the limited C API. So in Python 3.9, I moved the trashcan C API to the limited C API: https://docs.python.org/dev/whatsnew/3.9.html#id3

At the end, providing any backward compatibility with the stable ABI for Python 3.8 and older sounds useless and maybe we can simply remove the following 4 functions:

/* This is the old private API, invoked by the macros before 3.2.4.
   Kept for binary compatibility of extensions using the stable ABI. */
PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*);
PyAPI_FUNC(void) _PyTrash_destroy_chain(void);

/* This is the old private API, invoked by the macros before 3.9.
   Kept for binary compatibility of extensions using the stable ABI. */
PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyObject*);
PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void);

For the trashcan changes, see:

When I did these changes, I was afraid of breaking the C API, so I tried to reduce the risk by keeping _PyTrash_thread_deposit_object() and _PyTrash_thread_destroy_chain() "just in case". I was not brave enough to remove them.