@@ -43,6 +43,8 @@ Module Objects
43
43
to ``None ``); the caller is responsible for providing a :attr:`__file__`
44
44
attribute.
45
45
46
+ Return ``NULL `` with an exception set on error.
47
+
46
48
.. versionadded :: 3.3
47
49
48
50
.. versionchanged :: 3.4
@@ -265,6 +267,8 @@ of the following two module creation functions:
265
267
API version *module_api_version *. If that version does not match the version
266
268
of the running interpreter, a :exc: `RuntimeWarning ` is emitted.
267
269
270
+ Return ``NULL `` with an exception set on error.
271
+
268
272
.. note ::
269
273
270
274
Most uses of this function should be using :c:func: `PyModule_Create `
@@ -461,6 +465,8 @@ objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and
461
465
If that version does not match the version of the running interpreter,
462
466
a :exc: `RuntimeWarning ` is emitted.
463
467
468
+ Return ``NULL `` with an exception set on error.
469
+
464
470
.. note ::
465
471
466
472
Most uses of this function should be using :c:func: `PyModule_FromDefAndSpec `
@@ -601,23 +607,24 @@ state:
601
607
.. c :function :: int PyModule_AddIntConstant (PyObject *module, const char *name, long value)
602
608
603
609
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.
606
612
607
613
608
614
.. c :function :: int PyModule_AddStringConstant (PyObject *module, const char *name, const char *value)
609
615
610
616
Add a string constant to *module * as *name *. This convenience function can be
611
617
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.
613
620
614
621
615
622
.. c :macro :: PyModule_AddIntMacro(module, macro)
616
623
617
624
Add an int constant to *module *. The name and the value are taken from
618
625
*macro *. For example ``PyModule_AddIntMacro(module, AF_INET) `` adds the int
619
626
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.
621
628
622
629
623
630
.. c :macro :: PyModule_AddStringMacro(module, macro)
@@ -630,7 +637,7 @@ state:
630
637
The type object is finalized by calling internally :c:func: `PyType_Ready `.
631
638
The name of the type object is taken from the last component of
632
639
: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.
634
641
635
642
.. versionadded :: 3.9
636
643
@@ -643,7 +650,7 @@ state:
643
650
import machinery assumes the module does not support running without the
644
651
GIL. This function is only available in Python builds configured with
645
652
:option:`--disable-gil`.
646
- Return ``-1`` on error, ``0`` on success.
653
+ Return ``-1`` with an exception set on error, ``0`` on success.
647
654
648
655
.. versionadded:: 3.13
649
656
@@ -682,14 +689,14 @@ since multiple such modules can be created from a single definition.
682
689
683
690
The caller must hold the GIL.
684
691
685
- Return 0 on success or -1 on failure .
692
+ Return ``-1`` with an exception set on error, ``0`` on success .
686
693
687
694
.. versionadded:: 3.3
688
695
689
696
.. c:function:: int PyState_RemoveModule(PyModuleDef *def)
690
697
691
698
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 .
693
700
694
701
The caller must hold the GIL.
695
702
0 commit comments