Update postcohtable.
Changes
This MR updates postcohtable to work with Py3.
This repeats all changes from !226 (closed) for these files.
References
Here's some references for the changes made:
-
PyStr_FromString
is a drop-in replacement for the Py2PyString_FromString
: https://py3c.readthedocs.io/en/latest/reference.html#c.PyStr_FromString -
PyVarObject_HEAD_INIT
is similar toPyObject_HEAD_INIT
, but includes an argument for the 'size' of the type:
See https://docs.python.org/3/c-api/structures.html#c.PyVarObject_HEAD_INIT- In our case, this size should be set to 0, as we are defining 'static' types: https://docs.python.org/3/c-api/typeobj.html#c.PyVarObject.ob_size, and https://docs.python.org/3/c-api/typeobj.html#static-types
-
PyArg_ParseTuple
now uses the format 'y#' instead of 's#', meaning we're reading a 'bytes-like' object instead of a 'string' object. - Description of the new
PyModuleDef
object we use to pass arguments toPyModule_Create
: https://docs.python.org/3/c-api/module.html#c.PyModuleDef
Purpose
I intend to split !226 (closed)'s changes into a number of MRs, which won't be functional code versions themselves, but once complete will encompass the full set of changes to upgrade to py3.
This should provide useful code diffs for reviewers.
Edited by Timothy Davies