bpo-35059: Cast void* to PyObject* (GH-10650)

Don't pass void* to Python macros: use _PyObject_CAST().
This commit is contained in:
Victor Stinner 2018-11-22 10:25:22 +01:00 • committed by GitHub
parent b37672daf6
commit a42de742e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 11 deletions

View file

@ -1171,8 +1171,9 @@ This function is meant for internal and specialized purposes only.\n\
In most applications `threading.enumerate()` should be used instead.");
static void
release_sentinel(void *wr)
release_sentinel(void *wr_raw)
{
PyObject *wr = _PyObject_CAST(wr_raw);
/* Tricky: this function is called when the current thread state
is being deleted. Therefore, only simple C code can safely
execute here. */

View file

@ -1847,20 +1847,21 @@ _PyGC_Dump(PyGC_Head *g)
functions must always be available */
void
PyObject_GC_Track(void *op)
PyObject_GC_Track(void *op_raw)
{
PyObject *obj = (PyObject *)op;
PyObject *op = _PyObject_CAST(op_raw);
if (_PyObject_GC_IS_TRACKED(op)) {
_PyObject_ASSERT_FAILED_MSG(op,
"object already tracked "
"by the garbage collector");
}
_PyObject_GC_TRACK(obj);
_PyObject_GC_TRACK(op);
}
void
PyObject_GC_UnTrack(void *op)
PyObject_GC_UnTrack(void *op_raw)
{
PyObject *op = _PyObject_CAST(op_raw);
/* Obscure: the Py_TRASHCAN mechanism requires that we be able to
* call PyObject_GC_UnTrack twice on an object.
*/