@@ -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 `
@@ -436,6 +440,8 @@ objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and
436
440
If that version does not match the version of the running interpreter,
437
441
a :exc: `RuntimeWarning ` is emitted.
438
442
443
+ Return ``NULL `` with an exception set on error.
444
+
439
445
.. note ::
440
446
441
447
Most uses of this function should be using :c:func: `PyModule_FromDefAndSpec `
@@ -579,23 +585,24 @@ state:
579
585
.. c :function :: int PyModule_AddIntConstant (PyObject *module, const char *name, long value)
580
586
581
587
Add an integer constant to *module * as *name *. This convenience function can be
582
- used from the module's initialization function. Return `` -1 `` on error, `` 0 `` on
583
- success.
588
+ used from the module's initialization function.
589
+ Return `` -1 `` with an exception set on error, `` 0 `` on success.
584
590
585
591
586
592
.. c :function :: int PyModule_AddStringConstant (PyObject *module, const char *name, const char *value)
587
593
588
594
Add a string constant to *module * as *name *. This convenience function can be
589
595
used from the module's initialization function. The string *value * must be
590
- ``NULL ``-terminated. Return ``-1 `` on error, ``0 `` on success.
596
+ ``NULL ``-terminated.
597
+ Return ``-1 `` with an exception set on error, ``0 `` on success.
591
598
592
599
593
600
.. c :macro :: PyModule_AddIntMacro(module, macro)
594
601
595
602
Add an int constant to *module *. The name and the value are taken from
596
603
*macro *. For example ``PyModule_AddIntMacro(module, AF_INET) `` adds the int
597
604
constant *AF_INET * with the value of *AF_INET * to *module *.
598
- Return ``-1 `` on error, ``0 `` on success.
605
+ Return ``-1 `` with an exception set on error, ``0 `` on success.
599
606
600
607
601
608
.. c :macro :: PyModule_AddStringMacro(module, macro)
@@ -608,7 +615,7 @@ state:
608
615
The type object is finalized by calling internally :c:func: `PyType_Ready `.
609
616
The name of the type object is taken from the last component of
610
617
:c:member: `~PyTypeObject.tp_name ` after dot.
611
- Return ``-1 `` on error, ``0 `` on success.
618
+ Return ``-1 `` with an exception set on error, ``0 `` on success.
612
619
613
620
.. versionadded :: 3.9
614
621
@@ -647,14 +654,14 @@ since multiple such modules can be created from a single definition.
647
654
648
655
The caller must hold the GIL.
649
656
650
- Return 0 on success or -1 on failure .
657
+ Return ``-1`` with an exception set on error, ``0`` on success .
651
658
652
659
.. versionadded:: 3.3
653
660
654
661
.. c:function:: int PyState_RemoveModule(PyModuleDef *def)
655
662
656
663
Removes the module object created from *def * from the interpreter state.
657
- Return 0 on success or -1 on failure .
664
+ Return `` -1 `` with an exception set on error, `` 0 `` on success .
658
665
659
666
The caller must hold the GIL.
660
667
0 commit comments