https://github.com/python/cpython/commit/fa0cd47f3cf7064dd7f1870b9f388644f8255b23
commit: fa0cd47f3cf7064dd7f1870b9f388644f8255b23
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: methane <[email protected]>
date: 2026-11-04T03:21:38Z
summary:

Docs: fix code examples in the abi3t migration guide (GH-161247)

(cherry picked from commit 416e8d89f57ac39f0ca8187dc6bc44f5f6ff994c)

Co-authored-by: Inada Naoki <[email protected]>
Co-authored-by: Petr Viktorin <[email protected]>

files:
M Doc/howto/abi3t-migration.rst

diff --git a/Doc/howto/abi3t-migration.rst b/Doc/howto/abi3t-migration.rst
index 3aa11a0dbf653d..5faf05b89d388f 100644
--- a/Doc/howto/abi3t-migration.rst
+++ b/Doc/howto/abi3t-migration.rst
@@ -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::
 
@@ -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``
 .................
 
 
@@ -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:
@@ -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[] = {
@@ -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
    };
@@ -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:
 
@@ -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);
 
@@ -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>`.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to