Closed timfel closed 2 years ago
What happens during porting a C extension? Presumably initially the member is a PyObject *
. Will compilation in universal mode then fail? And once the member is been made an HPyField
, will compilation work in both CPython and universal mode?
I am wondering whether we need a legacy_defines or similar? Or at least some way to make it clear "these object members should use HPyField and those should use PyObject*".
What happens during porting a C extension? Presumably initially the member is a
PyObject *
. Will compilation in universal mode then fail? And once the member is been made anHPyField
, will compilation work in both CPython and universal mode?
As long as it is a PyObject, compilation in universal mode just fails. After it is an HPyField, it works in both CPython C ABI mode and HPy universal mode. It even works to have an HPyField and still use the legacy definition for members, since then you have to compile in C ABI mode and the HPyField is binary equivalent to PyObject in that mode. So afaics, nothing can go wrong even if you just partially port.
We already define
HPyMember_OBJECT
, but using it infails in universal mode, as the included test demonstrates, since the embedded member must an
HPyField
in this mode. This should work, since it's annoying to have to define getters/setters manually here.