Skip to content

Update postcohtable.

Timothy Davies requested to merge tdv-4-7-postcohtable into spiir-O4b-review

See 4.7 of https://docs.google.com/spreadsheets/d/1lQJzSIE6iUhlRQ5O4gjHBnIpsqFS7w3DQw3wX5_66P8/edit#gid=1881169084

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:

  1. PyStr_FromString is a drop-in replacement for the Py2 PyString_FromString: https://py3c.readthedocs.io/en/latest/reference.html#c.PyStr_FromString
  2. PyVarObject_HEAD_INIT is similar to PyObject_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
    1. 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
  3. PyArg_ParseTuple now uses the format 'y#' instead of 's#', meaning we're reading a 'bytes-like' object instead of a 'string' object.
    1. https://docs.python.org/3/c-api/arg.html#strings-and-buffers
  4. Description of the new PyModuleDef object we use to pass arguments to PyModule_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

Merge request reports

Loading