Created originally on Bitbucket by Devin Jeanpierre
CPython defines many macros like so:
#define PyWhatever_FOO(x) (((PyWhatever*)(x))->foo)
And callers can pass in a void*
, a PyWhatever*
, a PyObject*
, and it all
works assuming that the dynamic type is correct for the cast.
In PyPy, without these casts, a warning is emitted if you pass the "wrong" type, even though it would work in CPython. This breaks compatibility for projects that build with -Werror.