mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Add the co_extra field and accompanying APIs to code objects.
This completes PEP 523.
This commit is contained in:
parent
a9296e7f3b
commit
5c4de2863b
8 changed files with 139 additions and 3 deletions
|
@ -5608,3 +5608,17 @@ _Py_GetDXProfile(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
Py_ssize_t
|
||||
_PyEval_RequestCodeExtraIndex(freefunc free)
|
||||
{
|
||||
PyThreadState *tstate = PyThreadState_Get();
|
||||
Py_ssize_t new_index;
|
||||
|
||||
if (tstate->co_extra_user_count == MAX_CO_EXTRA_USERS - 1) {
|
||||
return -1;
|
||||
}
|
||||
new_index = tstate->co_extra_user_count++;
|
||||
tstate->co_extra_freefuncs[new_index] = free;
|
||||
return new_index;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue