8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 72eea51 commit 9bf3820Copy full SHA for 9bf3820
Include/internal/pycore_object.h
@@ -507,6 +507,25 @@ _Py_XNewRefWithLock(PyObject *obj)
507
return _Py_NewRefWithLock(obj);
508
}
509
510
+static inline void
511
+_PyObject_SetMaybeWeakref(PyObject *op)
512
+{
513
+ if (_Py_IsImmortal(op)) {
514
+ return;
515
+ }
516
+ for (;;) {
517
+ Py_ssize_t shared = _Py_atomic_load_ssize_relaxed(&op->ob_ref_shared);
518
+ if ((shared & _Py_REF_SHARED_FLAG_MASK) != 0) {
519
+ // Nothing to do if it's in WEAKREFS, QUEUED, or MERGED states.
520
521
522
+ if (_Py_atomic_compare_exchange_ssize(
523
+ &op->ob_ref_shared, &shared, shared | _Py_REF_MAYBE_WEAKREF)) {
524
525
526
527
+}
528
+
529
#endif
530
531
#ifdef Py_REF_DEBUG
0 commit comments