File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -526,3 +526,5 @@ typedef enum {
526526typedef int (* PyRefTracer )(PyObject * , PyRefTracerEvent event , void * );
527527PyAPI_FUNC (int ) PyRefTracer_SetTracer (PyRefTracer tracer , void * data );
528528PyAPI_FUNC (PyRefTracer ) PyRefTracer_GetTracer (void * * );
529+
530+ PyAPI_FUNC (int ) PyUnstable_Object_SetDeferredRefcount (PyObject * );
Original file line number Diff line number Diff line change @@ -2482,6 +2482,37 @@ _PyObject_SetDeferredRefcount(PyObject *op)
24822482#endif
24832483}
24842484
2485+ int
2486+ PyUnstable_Object_SetDeferredRefcount (PyObject * op )
2487+ {
2488+ #ifdef Py_GIL_DISABLED
2489+ if (!PyType_IS_GC (Py_TYPE (op )))
2490+ {
2491+ PyErr_SetString (PyExc_TypeError ,
2492+ "object is not tracked by the garbage collector" );
2493+ return -1 ;
2494+ }
2495+
2496+ if (!_Py_IsOwnedByCurrentThread (op ))
2497+ {
2498+ PyErr_SetString (PyExc_ValueError ,
2499+ "object is not owned by this thread" );
2500+ return -1 ;
2501+ }
2502+
2503+ if (op -> ob_ref_shared != 0 )
2504+ {
2505+ PyErr_SetString (PyExc_ValueError ,
2506+ "object is already in use by another thread" );
2507+ return -1 ;
2508+ }
2509+
2510+ _PyObject_SET_GC_BITS (op , _PyGC_BITS_DEFERRED );
2511+ op -> ob_ref_shared = _Py_REF_SHARED (_Py_REF_DEFERRED , 0 );
2512+ #endif
2513+ return 0 ;
2514+ }
2515+
24852516void
24862517_Py_ResurrectReference (PyObject * op )
24872518{
You can’t perform that action at this time.
0 commit comments