@@ -43,6 +43,8 @@ Module Objects
4343 to ``None ``); the caller is responsible for providing a :attr:`__file__`
4444 attribute.
4545
46+ Return ``NULL `` with an exception set on error.
47+
4648 .. versionadded :: 3.3
4749
4850 .. versionchanged :: 3.4
@@ -265,6 +267,8 @@ of the following two module creation functions:
265267 API version *module_api_version *. If that version does not match the version
266268 of the running interpreter, a :exc: `RuntimeWarning ` is emitted.
267269
270+ Return ``NULL `` with an exception set on error.
271+
268272 .. note ::
269273
270274 Most uses of this function should be using :c:func: `PyModule_Create `
@@ -461,6 +465,8 @@ objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and
461465 If that version does not match the version of the running interpreter,
462466 a :exc: `RuntimeWarning ` is emitted.
463467
468+ Return ``NULL `` with an exception set on error.
469+
464470 .. note ::
465471
466472 Most uses of this function should be using :c:func: `PyModule_FromDefAndSpec `
@@ -601,23 +607,24 @@ state:
601607.. c :function :: int PyModule_AddIntConstant (PyObject *module, const char *name, long value)
602608
603609 Add an integer constant to *module * as *name *. This convenience function can be
604- used from the module's initialization function. Return `` -1 `` on error, `` 0 `` on
605- success.
610+ used from the module's initialization function.
611+ Return `` -1 `` with an exception set on error, `` 0 `` on success.
606612
607613
608614.. c :function :: int PyModule_AddStringConstant (PyObject *module, const char *name, const char *value)
609615
610616 Add a string constant to *module * as *name *. This convenience function can be
611617 used from the module's initialization function. The string *value * must be
612- ``NULL ``-terminated. Return ``-1 `` on error, ``0 `` on success.
618+ ``NULL ``-terminated.
619+ Return ``-1 `` with an exception set on error, ``0 `` on success.
613620
614621
615622.. c :macro :: PyModule_AddIntMacro(module, macro)
616623
617624 Add an int constant to *module *. The name and the value are taken from
618625 *macro *. For example ``PyModule_AddIntMacro(module, AF_INET) `` adds the int
619626 constant *AF_INET * with the value of *AF_INET * to *module *.
620- Return ``-1 `` on error, ``0 `` on success.
627+ Return ``-1 `` with an exception set on error, ``0 `` on success.
621628
622629
623630.. c :macro :: PyModule_AddStringMacro(module, macro)
@@ -630,7 +637,7 @@ state:
630637 The type object is finalized by calling internally :c:func: `PyType_Ready `.
631638 The name of the type object is taken from the last component of
632639 :c:member: `~PyTypeObject.tp_name ` after dot.
633- Return ``-1 `` on error, ``0 `` on success.
640+ Return ``-1 `` with an exception set on error, ``0 `` on success.
634641
635642 .. versionadded :: 3.9
636643
@@ -643,7 +650,7 @@ state:
643650 import machinery assumes the module does not support running without the
644651 GIL. This function is only available in Python builds configured with
645652 :option:`--disable-gil`.
646- Return ``-1`` on error, ``0`` on success.
653+ Return ``-1`` with an exception set on error, ``0`` on success.
647654
648655 .. versionadded:: 3.13
649656
@@ -682,14 +689,14 @@ since multiple such modules can be created from a single definition.
682689
683690 The caller must hold the GIL.
684691
685- Return 0 on success or -1 on failure .
692+ Return ``-1`` with an exception set on error, ``0`` on success .
686693
687694 .. versionadded:: 3.3
688695
689696.. c:function:: int PyState_RemoveModule(PyModuleDef *def)
690697
691698 Removes the module object created from *def * from the interpreter state.
692- Return 0 on success or -1 on failure .
699+ Return `` -1 `` with an exception set on error, `` 0 `` on success .
693700
694701 The caller must hold the GIL.
695702
0 commit comments