Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Doc/howto/abi3t-migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ For reference, here are direct links for several popular build tools:
You may want to verify that the tool set the right flag by temporarily adding the
following just after ``#include <Python.h>``::

#if Py_TARGET_ABI3T+0 <= 0x30f0000
#if Py_TARGET_ABI3T+0 < 0x30f0000
#error "abi3t define is not set!"
#endif

This should result in a different error than "``abi3t`` define is not set".
This should result in a different error than "``abi3t`` define is not set". (If you get no error at all, either the module is already ported or you're not compiling the code you changed.)

.. seealso::

Expand Down Expand Up @@ -357,13 +357,13 @@ It should be a :c:type:`PyModuleDef_Slot` array like the following:
static PyModuleDef_Slot my_slots[] = {
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_create, my_module_create},
{Py_mod_create, create_module},
{Py_mod_exec, my_first_module_exec},
{Py_mod_exec, my_second_module_exec},
{0, NULL}
};
``py_mod_create``
``Py_mod_create``
.................


Expand All @@ -383,7 +383,7 @@ Commonly, the information is static and you can refer to it directly.
defining several functions instead.)


Multiple ``py_mod_exec``
Multiple ``Py_mod_exec``
........................

If you have *more than one* :c:macro:`Py_mod_exec` entry, consolidate them:
Expand All @@ -396,6 +396,7 @@ with it.
static int my_module_exec(PyObject *module) {
if (my_first_module_exec(module) < 0) return -1;
if (my_second_module_exec(module) < 0) return -1;
return 0;
}
static PyModuleDef_Slot my_slots[] = {
Expand Down Expand Up @@ -423,8 +424,8 @@ definitions to :c:macro:`PySlot_DATA` and :c:macro:`PySlot_FUNC`:
...
PySlot_DATA(Py_mod_gil, Py_MOD_GIL_NOT_USED),
PySlot_DATA(Py_mod_multiple_interpreters,
Py_MOD_PER_INTERPRETER_GIL_SUPPORTED)
PySlot_FUNC(Py_mod_create, my_module_create),
Py_MOD_PER_INTERPRETER_GIL_SUPPORTED),
PySlot_FUNC(Py_mod_create, create_module),
PySlot_FUNC(Py_mod_exec, my_module_exec),
PySlot_END
};
Expand Down Expand Up @@ -475,7 +476,7 @@ These functions are typically used for two purposes:
...
PySlot_STATIC_DATA(Py_mod_token, &my_token),
PySlot_END
}
};
Then, switch from :c:func:`PyModule_GetDef` calls such as:

Expand Down Expand Up @@ -508,7 +509,7 @@ These functions are typically used for two purposes:
.. code-block::
:class: good
PyObject *module = PyType_GetModuleByToken(type, my_token);
PyObject *module = PyType_GetModuleByToken(type, &my_token);
/* handle error; use module */
Py_XDECREF(module);
Expand Down Expand Up @@ -655,11 +656,12 @@ There are two main ways to get the right class:
.. code-block::
:class: good
PyTypeObject cls;
PyTypeObject *cls;
if (PyType_GetBaseByToken(Py_TYPE(obj), my_tp_token, &cls) < 0) {
/* handle error */
}
CustomObjectData *data = PyObject_GetTypeData(obj, cls);
Py_DECREF(cls);
Type tokens work similarly to module tokens covered :ref:`earlier in this
guide <abi3t-migration-module-token>`.
Expand Down
Loading