Closed javaprog closed 3 years ago
Thanks for the PR. py3c should also explicitly check that these are set to NULL in Python 2, so people can't use them where they don't work.
py3c should also explicitly check that these are set to NULL in Python 2, so people can't use them where they don't work.
Good idea - how would you try to achieve that? My approach would be to turn the macro PyModule_Create
into a function and have it check the members of the passed struct before calling PyInit_Module3
.
Yes, a static function sounds right for this. I guess it would also be possible to make it a macro using the ternary operator, but that might make it unreadable.
On November 25, 2020 5:02:45 PM GMT+01:00, Michael Rudolf notifications@github.com wrote:
py3c should also explicitly check that these are set to NULL in Python 2, so people can't use them where they don't work.
Good idea - how would you try to achieve that? My approach would be to turn the macro
PyModule_Create
into a function and have it check the members of the passed struct before callingPyInit_Module3
.-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/encukou/py3c/pull/35#issuecomment-733797503
-- Sent from my Android device with K-9 Mail. Please excuse my brevity.
Thanks! I've added some documentation, and rebased to avoid a CHANGELOG conflict.
By extending the
PyModuleDef
struct for Python 2 with the fields present in Python 3, client code can provide field initializers to avoid the-Wmissing-field-initializers
compiler warning.