Skip to content

Commit

Permalink
Extra guards around _Py_RefTotal usage.
Browse files Browse the repository at this point in the history
Testing in a Python 3.9 interpreter with Py_TRACE_REFS defined revealed another issue, the separation of Py_RefTotal out to depend on Py_REF_DEBUG.
  • Loading branch information
jamadden committed Feb 19, 2020
1 parent 0e957a4 commit 6ee588d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion persistent/cPickleCache.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
/* This is called from the deallocation function after the
interpreter has untracked the reference. Track it again.
Starting in 3.9, these functions aren't available with the
stable (limited) API.
stable (limited) API and are only defined when they do something.
XXX: Why? Why not simply INCREF it? The CPython documentation
explicitly states these functions are for internal use only.
Expand All @@ -640,8 +640,13 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
/* Don't increment total refcount as a result of the
shenanigans played in this function. The _Py_NewReference()
call above creates artificial references to v.
This variable was was completely removed in 3.9 unless
Py_REF_DEBUG is also defined.
*/
#if PY_VERSION_HEX < 0x03090000 || defined(Py_REF_DEBUG)
_Py_RefTotal--;
#endif
assert(dead_pers_obj->ob_type);
#else
Py_INCREF(dead_pers_obj);
Expand Down

0 comments on commit 6ee588d

Please sign in to comment.