Skip to content

Commit bf07654

Browse files
Some comments are added
1 parent f0a09c3 commit bf07654

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Modules/_testinternalcapi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,9 +2431,11 @@ stackref_from_object_new(PyObject *self, PyObject *op)
24312431
static PyObject *
24322432
stackref_from_object_steal_with_incref(PyObject *self, PyObject *op)
24332433
{
2434+
// The next two lines are equivalent to PyStackRef_FromPyObjectNew.
24342435
Py_INCREF(op);
24352436
_PyStackRef ref = PyStackRef_FromPyObjectSteal(op);
24362437
PyObject *obj = _PyStackRef_AsTuple(ref, op);
2438+
// The next two lines are equivalent to PyStackRef_CLOSE.
24372439
PyObject *op2 = PyStackRef_AsPyObjectSteal(ref);
24382440
Py_DECREF(op2);
24392441
return obj;
@@ -2443,6 +2445,7 @@ static PyObject *
24432445
stackref_make_heap_safe(PyObject *self, PyObject *op)
24442446
{
24452447
_PyStackRef ref = PyStackRef_FromPyObjectNew(op);
2448+
// In no-GIL production build ref2 is equal to ref.
24462449
_PyStackRef ref2 = PyStackRef_MakeHeapSafe(ref);
24472450
PyObject *obj = _PyStackRef_AsTuple(ref2, op);
24482451
PyStackRef_CLOSE(ref2);
@@ -2455,6 +2458,7 @@ stackref_make_heap_safe_with_borrow(PyObject *self, PyObject *op)
24552458
_PyStackRef ref = PyStackRef_FromPyObjectNew(op);
24562459
_PyStackRef ref2 = PyStackRef_Borrow(ref);
24572460
_PyStackRef ref3 = PyStackRef_MakeHeapSafe(ref2);
2461+
// We can close ref, since ref3 is heap safe.
24582462
PyStackRef_CLOSE(ref);
24592463
PyObject *obj = _PyStackRef_AsTuple(ref3, op);
24602464
PyStackRef_CLOSE(ref3);
@@ -2464,6 +2468,7 @@ stackref_make_heap_safe_with_borrow(PyObject *self, PyObject *op)
24642468
static PyObject *
24652469
stackref_strong_reference(PyObject *self, PyObject *op)
24662470
{
2471+
// The next two lines are equivalent to op2 = Py_NewRef(op).
24672472
_PyStackRef ref = PyStackRef_FromPyObjectBorrow(op);
24682473
PyObject *op2 = PyStackRef_AsPyObjectSteal(ref);
24692474
_PyStackRef ref2 = PyStackRef_FromPyObjectSteal(op2);
@@ -2485,7 +2490,9 @@ static PyObject *
24852490
stackref_dup_borrowed_with_close(PyObject *self, PyObject *op)
24862491
{
24872492
_PyStackRef ref = PyStackRef_FromPyObjectBorrow(op);
2493+
// In no-GIL production build ref2 is equal to ref.
24882494
_PyStackRef ref2 = PyStackRef_DUP(ref);
2495+
// In production build closing borrowed ref is no-op.
24892496
PyStackRef_XCLOSE(ref);
24902497
PyObject *obj = _PyStackRef_AsTuple(ref2, op);
24912498
PyStackRef_XCLOSE(ref2);

0 commit comments

Comments
 (0)