mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-91051: allow setting a callback hook on PyType_Modified (GH-97875)
This commit is contained in:
parent
8367ca136e
commit
82ccbf69a8
9 changed files with 462 additions and 5 deletions
|
@ -224,6 +224,9 @@ struct _typeobject {
|
|||
|
||||
destructor tp_finalize;
|
||||
vectorcallfunc tp_vectorcall;
|
||||
|
||||
/* bitset of which type-watchers care about this type */
|
||||
char tp_watched;
|
||||
};
|
||||
|
||||
/* This struct is used by the specializer
|
||||
|
@ -510,3 +513,11 @@ Py_DEPRECATED(3.11) typedef int UsingDeprecatedTrashcanMacro;
|
|||
|
||||
PyAPI_FUNC(int) _PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg);
|
||||
PyAPI_FUNC(void) _PyObject_ClearManagedDict(PyObject *obj);
|
||||
|
||||
#define TYPE_MAX_WATCHERS 8
|
||||
|
||||
typedef int(*PyType_WatchCallback)(PyTypeObject *);
|
||||
PyAPI_FUNC(int) PyType_AddWatcher(PyType_WatchCallback callback);
|
||||
PyAPI_FUNC(int) PyType_ClearWatcher(int watcher_id);
|
||||
PyAPI_FUNC(int) PyType_Watch(int watcher_id, PyObject *type);
|
||||
PyAPI_FUNC(int) PyType_Unwatch(int watcher_id, PyObject *type);
|
||||
|
|
|
@ -166,6 +166,7 @@ struct _is {
|
|||
struct atexit_state atexit;
|
||||
|
||||
PyObject *audit_hooks;
|
||||
PyType_WatchCallback type_watchers[TYPE_MAX_WATCHERS];
|
||||
|
||||
struct _Py_unicode_state unicode;
|
||||
struct _Py_float_state float_state;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue