Skip to content

_PyTrash_begin and _PyTrash_end do not have implementation #128910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sobolevn opened this issue Jan 16, 2025 · 1 comment
Closed

_PyTrash_begin and _PyTrash_end do not have implementation #128910

sobolevn opened this issue Jan 16, 2025 · 1 comment

Comments

@sobolevn
Copy link
Member

sobolevn commented Jan 16, 2025

We only have this left for _PyTrash_begin and _PyTrash_end:

~/Desktop/cpython2  main ✗                                                                
» ag _PyTrash_begin .
Misc/NEWS.d/3.9.0a5.rst
1217:PyThreadState attributes, but call new private _PyTrash_begin() and

Include/cpython/object.h
479:PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
» ag _PyTrash_end .  
Misc/NEWS.d/3.9.0a5.rst
1218:_PyTrash_end() functions which hide implementation details.

Include/cpython/object.h
480:PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);                  

Source:

/* Python 3.9 private API, invoked by the macros below. */
PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);

They don't even have implementations. Looks like that they used to be called from Py_TRASHCAN_BEGIN and Py_TRASHCAN_END in 3.9:

PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
#define PyTrash_UNWIND_LEVEL 50
#define Py_TRASHCAN_BEGIN_CONDITION(op, cond) \
do { \
PyThreadState *_tstate = NULL; \
/* If "cond" is false, then _tstate remains NULL and the deallocator \
* is run normally without involving the trashcan */ \
if (cond) { \
_tstate = PyThreadState_GET(); \
if (_PyTrash_begin(_tstate, _PyObject_CAST(op))) { \
break; \
} \
}
/* The body of the deallocator is here. */
#define Py_TRASHCAN_END \
if (_tstate) { \
_PyTrash_end(_tstate); \
} \
} while (0);
#define Py_TRASHCAN_BEGIN(op, dealloc) \
Py_TRASHCAN_BEGIN_CONDITION(op, \
Py_TYPE(op)->tp_dealloc == (destructor)(dealloc))

But, they are unused since #117763 in ~3.11

What should we do?

  1. Nothing
  2. Remove them
  3. Raise deprecation warning when they are called (but they return void, it would be hard to do)

CC @markshannon @vstinner

Linked PRs

@vstinner
Copy link
Member

Please remove them. It's misleading to announce that we have two functions which they don't exist!

There is no backward compatibility concerns since this API is excluded from the limited C API / the stable ABI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants