You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

264 lines
8.9 KiB

Merged revisions 60176-60209 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60178 | georg.brandl | 2008-01-21 22:05:49 +0100 (Mon, 21 Jan 2008) | 2 lines #1715: include sub-extension modules in pydoc text output. ........ r60179 | georg.brandl | 2008-01-21 22:14:21 +0100 (Mon, 21 Jan 2008) | 2 lines Add a "const" to make gcc happy. ........ r60180 | georg.brandl | 2008-01-21 22:19:07 +0100 (Mon, 21 Jan 2008) | 2 lines Add the correct build dir when building with pydebug. ........ r60181 | georg.brandl | 2008-01-21 22:23:15 +0100 (Mon, 21 Jan 2008) | 3 lines Patch #1720595: add T_BOOL to the range of structmember types. Patch by Angelo Mottola, reviewed by MvL, tests by me. ........ r60182 | georg.brandl | 2008-01-21 22:28:32 +0100 (Mon, 21 Jan 2008) | 2 lines Reformat some ugly code. ........ r60187 | brett.cannon | 2008-01-22 00:50:16 +0100 (Tue, 22 Jan 2008) | 4 lines Make's MAKEFLAGS variable is set to a string containing the single-letter arguments to Make. This means there are no hyphens. Fix the '-s' check to silence distutils to now work. ........ r60188 | gregory.p.smith | 2008-01-22 01:19:41 +0100 (Tue, 22 Jan 2008) | 3 lines accepts and closes issue #1221598: adds an optional callback to ftplib.FTP storbinary() and storlines() methods. ........ r60189 | gregory.p.smith | 2008-01-22 02:12:02 +0100 (Tue, 22 Jan 2008) | 2 lines Replace spam.acquire() try: ... finally: spam.release() with "with spam:" ........ r60190 | gregory.p.smith | 2008-01-22 02:20:42 +0100 (Tue, 22 Jan 2008) | 4 lines - Fix Issue #1703448: A joined thread could show up in the threading.enumerate() list after the join() for a brief period until it actually exited. ........ r60193 | georg.brandl | 2008-01-22 08:53:31 +0100 (Tue, 22 Jan 2008) | 2 lines Fix \xhh specs, #1889. ........ r60198 | christian.heimes | 2008-01-22 16:01:25 +0100 (Tue, 22 Jan 2008) | 1 line Fixed a missing (X) in define ........ r60199 | christian.heimes | 2008-01-22 16:25:18 +0100 (Tue, 22 Jan 2008) | 2 lines Don't repeat yourself Added the macros PyModule_AddIntMacro and PyModule_AddStringMacro. They shorten PyModule_AddIntConstant(m, "AF_INET", AF_INET) to PyModule_AddIntMacro(m, AF_INET) ........ r60201 | raymond.hettinger | 2008-01-22 20:51:41 +0100 (Tue, 22 Jan 2008) | 1 line Document when to use izip_longest(). ........ r60202 | georg.brandl | 2008-01-22 20:56:03 +0100 (Tue, 22 Jan 2008) | 2 lines Fix for #1087741 patch. ........ r60203 | raymond.hettinger | 2008-01-22 21:18:53 +0100 (Tue, 22 Jan 2008) | 1 line Give zip() the same guarantee as izip() for left-to-right evaluation. ........ r60204 | raymond.hettinger | 2008-01-22 23:09:26 +0100 (Tue, 22 Jan 2008) | 1 line Improve variable name in sample code ........ r60205 | gregory.p.smith | 2008-01-23 00:15:34 +0100 (Wed, 23 Jan 2008) | 2 lines docstring and comment updates suggested by Giampaolo Rodola' ........ r60207 | raymond.hettinger | 2008-01-23 01:04:40 +0100 (Wed, 23 Jan 2008) | 1 line Let pprint() support sets and frozensets (suggested by David Mertz). ........ r60208 | guido.van.rossum | 2008-01-23 02:18:27 +0100 (Wed, 23 Jan 2008) | 4 lines I'm tired of these tests breaking at Google due to our large number of users and groups in LDAP/NIS. So I'm limiting the extra-heavy part of the tests to passwd/group files with at most 1000 entries. ........
18 years ago
Merged revisions 60176-60209 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60178 | georg.brandl | 2008-01-21 22:05:49 +0100 (Mon, 21 Jan 2008) | 2 lines #1715: include sub-extension modules in pydoc text output. ........ r60179 | georg.brandl | 2008-01-21 22:14:21 +0100 (Mon, 21 Jan 2008) | 2 lines Add a "const" to make gcc happy. ........ r60180 | georg.brandl | 2008-01-21 22:19:07 +0100 (Mon, 21 Jan 2008) | 2 lines Add the correct build dir when building with pydebug. ........ r60181 | georg.brandl | 2008-01-21 22:23:15 +0100 (Mon, 21 Jan 2008) | 3 lines Patch #1720595: add T_BOOL to the range of structmember types. Patch by Angelo Mottola, reviewed by MvL, tests by me. ........ r60182 | georg.brandl | 2008-01-21 22:28:32 +0100 (Mon, 21 Jan 2008) | 2 lines Reformat some ugly code. ........ r60187 | brett.cannon | 2008-01-22 00:50:16 +0100 (Tue, 22 Jan 2008) | 4 lines Make's MAKEFLAGS variable is set to a string containing the single-letter arguments to Make. This means there are no hyphens. Fix the '-s' check to silence distutils to now work. ........ r60188 | gregory.p.smith | 2008-01-22 01:19:41 +0100 (Tue, 22 Jan 2008) | 3 lines accepts and closes issue #1221598: adds an optional callback to ftplib.FTP storbinary() and storlines() methods. ........ r60189 | gregory.p.smith | 2008-01-22 02:12:02 +0100 (Tue, 22 Jan 2008) | 2 lines Replace spam.acquire() try: ... finally: spam.release() with "with spam:" ........ r60190 | gregory.p.smith | 2008-01-22 02:20:42 +0100 (Tue, 22 Jan 2008) | 4 lines - Fix Issue #1703448: A joined thread could show up in the threading.enumerate() list after the join() for a brief period until it actually exited. ........ r60193 | georg.brandl | 2008-01-22 08:53:31 +0100 (Tue, 22 Jan 2008) | 2 lines Fix \xhh specs, #1889. ........ r60198 | christian.heimes | 2008-01-22 16:01:25 +0100 (Tue, 22 Jan 2008) | 1 line Fixed a missing (X) in define ........ r60199 | christian.heimes | 2008-01-22 16:25:18 +0100 (Tue, 22 Jan 2008) | 2 lines Don't repeat yourself Added the macros PyModule_AddIntMacro and PyModule_AddStringMacro. They shorten PyModule_AddIntConstant(m, "AF_INET", AF_INET) to PyModule_AddIntMacro(m, AF_INET) ........ r60201 | raymond.hettinger | 2008-01-22 20:51:41 +0100 (Tue, 22 Jan 2008) | 1 line Document when to use izip_longest(). ........ r60202 | georg.brandl | 2008-01-22 20:56:03 +0100 (Tue, 22 Jan 2008) | 2 lines Fix for #1087741 patch. ........ r60203 | raymond.hettinger | 2008-01-22 21:18:53 +0100 (Tue, 22 Jan 2008) | 1 line Give zip() the same guarantee as izip() for left-to-right evaluation. ........ r60204 | raymond.hettinger | 2008-01-22 23:09:26 +0100 (Tue, 22 Jan 2008) | 1 line Improve variable name in sample code ........ r60205 | gregory.p.smith | 2008-01-23 00:15:34 +0100 (Wed, 23 Jan 2008) | 2 lines docstring and comment updates suggested by Giampaolo Rodola' ........ r60207 | raymond.hettinger | 2008-01-23 01:04:40 +0100 (Wed, 23 Jan 2008) | 1 line Let pprint() support sets and frozensets (suggested by David Mertz). ........ r60208 | guido.van.rossum | 2008-01-23 02:18:27 +0100 (Wed, 23 Jan 2008) | 4 lines I'm tired of these tests breaking at Google due to our large number of users and groups in LDAP/NIS. So I'm limiting the extra-heavy part of the tests to passwd/group files with at most 1000 entries. ........
18 years ago
Merged revisions 60176-60209 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60178 | georg.brandl | 2008-01-21 22:05:49 +0100 (Mon, 21 Jan 2008) | 2 lines #1715: include sub-extension modules in pydoc text output. ........ r60179 | georg.brandl | 2008-01-21 22:14:21 +0100 (Mon, 21 Jan 2008) | 2 lines Add a "const" to make gcc happy. ........ r60180 | georg.brandl | 2008-01-21 22:19:07 +0100 (Mon, 21 Jan 2008) | 2 lines Add the correct build dir when building with pydebug. ........ r60181 | georg.brandl | 2008-01-21 22:23:15 +0100 (Mon, 21 Jan 2008) | 3 lines Patch #1720595: add T_BOOL to the range of structmember types. Patch by Angelo Mottola, reviewed by MvL, tests by me. ........ r60182 | georg.brandl | 2008-01-21 22:28:32 +0100 (Mon, 21 Jan 2008) | 2 lines Reformat some ugly code. ........ r60187 | brett.cannon | 2008-01-22 00:50:16 +0100 (Tue, 22 Jan 2008) | 4 lines Make's MAKEFLAGS variable is set to a string containing the single-letter arguments to Make. This means there are no hyphens. Fix the '-s' check to silence distutils to now work. ........ r60188 | gregory.p.smith | 2008-01-22 01:19:41 +0100 (Tue, 22 Jan 2008) | 3 lines accepts and closes issue #1221598: adds an optional callback to ftplib.FTP storbinary() and storlines() methods. ........ r60189 | gregory.p.smith | 2008-01-22 02:12:02 +0100 (Tue, 22 Jan 2008) | 2 lines Replace spam.acquire() try: ... finally: spam.release() with "with spam:" ........ r60190 | gregory.p.smith | 2008-01-22 02:20:42 +0100 (Tue, 22 Jan 2008) | 4 lines - Fix Issue #1703448: A joined thread could show up in the threading.enumerate() list after the join() for a brief period until it actually exited. ........ r60193 | georg.brandl | 2008-01-22 08:53:31 +0100 (Tue, 22 Jan 2008) | 2 lines Fix \xhh specs, #1889. ........ r60198 | christian.heimes | 2008-01-22 16:01:25 +0100 (Tue, 22 Jan 2008) | 1 line Fixed a missing (X) in define ........ r60199 | christian.heimes | 2008-01-22 16:25:18 +0100 (Tue, 22 Jan 2008) | 2 lines Don't repeat yourself Added the macros PyModule_AddIntMacro and PyModule_AddStringMacro. They shorten PyModule_AddIntConstant(m, "AF_INET", AF_INET) to PyModule_AddIntMacro(m, AF_INET) ........ r60201 | raymond.hettinger | 2008-01-22 20:51:41 +0100 (Tue, 22 Jan 2008) | 1 line Document when to use izip_longest(). ........ r60202 | georg.brandl | 2008-01-22 20:56:03 +0100 (Tue, 22 Jan 2008) | 2 lines Fix for #1087741 patch. ........ r60203 | raymond.hettinger | 2008-01-22 21:18:53 +0100 (Tue, 22 Jan 2008) | 1 line Give zip() the same guarantee as izip() for left-to-right evaluation. ........ r60204 | raymond.hettinger | 2008-01-22 23:09:26 +0100 (Tue, 22 Jan 2008) | 1 line Improve variable name in sample code ........ r60205 | gregory.p.smith | 2008-01-23 00:15:34 +0100 (Wed, 23 Jan 2008) | 2 lines docstring and comment updates suggested by Giampaolo Rodola' ........ r60207 | raymond.hettinger | 2008-01-23 01:04:40 +0100 (Wed, 23 Jan 2008) | 1 line Let pprint() support sets and frozensets (suggested by David Mertz). ........ r60208 | guido.van.rossum | 2008-01-23 02:18:27 +0100 (Wed, 23 Jan 2008) | 4 lines I'm tired of these tests breaking at Google due to our large number of users and groups in LDAP/NIS. So I'm limiting the extra-heavy part of the tests to passwd/group files with at most 1000 entries. ........
18 years ago
Merged revisions 60176-60209 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r60178 | georg.brandl | 2008-01-21 22:05:49 +0100 (Mon, 21 Jan 2008) | 2 lines #1715: include sub-extension modules in pydoc text output. ........ r60179 | georg.brandl | 2008-01-21 22:14:21 +0100 (Mon, 21 Jan 2008) | 2 lines Add a "const" to make gcc happy. ........ r60180 | georg.brandl | 2008-01-21 22:19:07 +0100 (Mon, 21 Jan 2008) | 2 lines Add the correct build dir when building with pydebug. ........ r60181 | georg.brandl | 2008-01-21 22:23:15 +0100 (Mon, 21 Jan 2008) | 3 lines Patch #1720595: add T_BOOL to the range of structmember types. Patch by Angelo Mottola, reviewed by MvL, tests by me. ........ r60182 | georg.brandl | 2008-01-21 22:28:32 +0100 (Mon, 21 Jan 2008) | 2 lines Reformat some ugly code. ........ r60187 | brett.cannon | 2008-01-22 00:50:16 +0100 (Tue, 22 Jan 2008) | 4 lines Make's MAKEFLAGS variable is set to a string containing the single-letter arguments to Make. This means there are no hyphens. Fix the '-s' check to silence distutils to now work. ........ r60188 | gregory.p.smith | 2008-01-22 01:19:41 +0100 (Tue, 22 Jan 2008) | 3 lines accepts and closes issue #1221598: adds an optional callback to ftplib.FTP storbinary() and storlines() methods. ........ r60189 | gregory.p.smith | 2008-01-22 02:12:02 +0100 (Tue, 22 Jan 2008) | 2 lines Replace spam.acquire() try: ... finally: spam.release() with "with spam:" ........ r60190 | gregory.p.smith | 2008-01-22 02:20:42 +0100 (Tue, 22 Jan 2008) | 4 lines - Fix Issue #1703448: A joined thread could show up in the threading.enumerate() list after the join() for a brief period until it actually exited. ........ r60193 | georg.brandl | 2008-01-22 08:53:31 +0100 (Tue, 22 Jan 2008) | 2 lines Fix \xhh specs, #1889. ........ r60198 | christian.heimes | 2008-01-22 16:01:25 +0100 (Tue, 22 Jan 2008) | 1 line Fixed a missing (X) in define ........ r60199 | christian.heimes | 2008-01-22 16:25:18 +0100 (Tue, 22 Jan 2008) | 2 lines Don't repeat yourself Added the macros PyModule_AddIntMacro and PyModule_AddStringMacro. They shorten PyModule_AddIntConstant(m, "AF_INET", AF_INET) to PyModule_AddIntMacro(m, AF_INET) ........ r60201 | raymond.hettinger | 2008-01-22 20:51:41 +0100 (Tue, 22 Jan 2008) | 1 line Document when to use izip_longest(). ........ r60202 | georg.brandl | 2008-01-22 20:56:03 +0100 (Tue, 22 Jan 2008) | 2 lines Fix for #1087741 patch. ........ r60203 | raymond.hettinger | 2008-01-22 21:18:53 +0100 (Tue, 22 Jan 2008) | 1 line Give zip() the same guarantee as izip() for left-to-right evaluation. ........ r60204 | raymond.hettinger | 2008-01-22 23:09:26 +0100 (Tue, 22 Jan 2008) | 1 line Improve variable name in sample code ........ r60205 | gregory.p.smith | 2008-01-23 00:15:34 +0100 (Wed, 23 Jan 2008) | 2 lines docstring and comment updates suggested by Giampaolo Rodola' ........ r60207 | raymond.hettinger | 2008-01-23 01:04:40 +0100 (Wed, 23 Jan 2008) | 1 line Let pprint() support sets and frozensets (suggested by David Mertz). ........ r60208 | guido.van.rossum | 2008-01-23 02:18:27 +0100 (Wed, 23 Jan 2008) | 4 lines I'm tired of these tests breaking at Google due to our large number of users and groups in LDAP/NIS. So I'm limiting the extra-heavy part of the tests to passwd/group files with at most 1000 entries. ........
18 years ago
  1. .. highlightlang:: c
  2. .. _moduleobjects:
  3. Module Objects
  4. --------------
  5. .. index:: object: module
  6. There are only a few functions special to module objects.
  7. .. c:var:: PyTypeObject PyModule_Type
  8. .. index:: single: ModuleType (in module types)
  9. This instance of :c:type:`PyTypeObject` represents the Python module type. This
  10. is exposed to Python programs as ``types.ModuleType``.
  11. .. c:function:: int PyModule_Check(PyObject *p)
  12. Return true if *p* is a module object, or a subtype of a module object.
  13. .. c:function:: int PyModule_CheckExact(PyObject *p)
  14. Return true if *p* is a module object, but not a subtype of
  15. :c:data:`PyModule_Type`.
  16. .. c:function:: PyObject* PyModule_NewObject(PyObject *name)
  17. .. index::
  18. single: __name__ (module attribute)
  19. single: __doc__ (module attribute)
  20. single: __file__ (module attribute)
  21. single: __package__ (module attribute)
  22. single: __loader__ (module attribute)
  23. Return a new module object with the :attr:`__name__` attribute set to *name*.
  24. The module's :attr:`__name__`, :attr:`__doc__`, :attr:`__package__`, and
  25. :attr:`__loader__` attributes are filled in (all but :attr:`__name__` are set
  26. to ``None``); the caller is responsible for providing a :attr:`__file__`
  27. attribute.
  28. .. versionadded:: 3.3
  29. .. versionchanged:: 3.4
  30. :attr:`__package__` and :attr:`__loader__` are set to ``None``.
  31. .. c:function:: PyObject* PyModule_New(const char *name)
  32. Similar to :c:func:`PyImport_NewObject`, but the name is an UTF-8 encoded
  33. string instead of a Unicode object.
  34. .. c:function:: PyObject* PyModule_GetDict(PyObject *module)
  35. .. index:: single: __dict__ (module attribute)
  36. Return the dictionary object that implements *module*'s namespace; this object
  37. is the same as the :attr:`__dict__` attribute of the module object. This
  38. function never fails. It is recommended extensions use other
  39. :c:func:`PyModule_\*` and :c:func:`PyObject_\*` functions rather than directly
  40. manipulate a module's :attr:`__dict__`.
  41. .. c:function:: PyObject* PyModule_GetNameObject(PyObject *module)
  42. .. index::
  43. single: __name__ (module attribute)
  44. single: SystemError (built-in exception)
  45. Return *module*'s :attr:`__name__` value. If the module does not provide one,
  46. or if it is not a string, :exc:`SystemError` is raised and *NULL* is returned.
  47. .. versionadded:: 3.3
  48. .. c:function:: char* PyModule_GetName(PyObject *module)
  49. Similar to :c:func:`PyModule_GetNameObject` but return the name encoded to
  50. ``'utf-8'``.
  51. .. c:function:: PyObject* PyModule_GetFilenameObject(PyObject *module)
  52. .. index::
  53. single: __file__ (module attribute)
  54. single: SystemError (built-in exception)
  55. Return the name of the file from which *module* was loaded using *module*'s
  56. :attr:`__file__` attribute. If this is not defined, or if it is not a
  57. unicode string, raise :exc:`SystemError` and return *NULL*; otherwise return
  58. a reference to a Unicode object.
  59. .. versionadded:: 3.2
  60. .. c:function:: char* PyModule_GetFilename(PyObject *module)
  61. Similar to :c:func:`PyModule_GetFilenameObject` but return the filename
  62. encoded to 'utf-8'.
  63. .. deprecated:: 3.2
  64. :c:func:`PyModule_GetFilename` raises :c:type:`UnicodeEncodeError` on
  65. unencodable filenames, use :c:func:`PyModule_GetFilenameObject` instead.
  66. .. c:function:: void* PyModule_GetState(PyObject *module)
  67. Return the "state" of the module, that is, a pointer to the block of memory
  68. allocated at module creation time, or *NULL*. See
  69. :c:member:`PyModuleDef.m_size`.
  70. .. c:function:: PyModuleDef* PyModule_GetDef(PyObject *module)
  71. Return a pointer to the :c:type:`PyModuleDef` struct from which the module was
  72. created, or *NULL* if the module wasn't created with
  73. :c:func:`PyModule_Create`.i
  74. .. c:function:: PyObject* PyState_FindModule(PyModuleDef *def)
  75. Returns the module object that was created from *def* for the current interpreter.
  76. This method requires that the module object has been attached to the interpreter state with
  77. :c:func:`PyState_AddModule` beforehand. In case the corresponding module object is not
  78. found or has not been attached to the interpreter state yet, it returns NULL.
  79. .. c:function:: int PyState_AddModule(PyObject *module, PyModuleDef *def)
  80. Attaches the module object passed to the function to the interpreter state. This allows
  81. the module object to be accessible via
  82. :c:func:`PyState_FindModule`.
  83. .. versionadded:: 3.3
  84. .. c:function:: int PyState_RemoveModule(PyModuleDef *def)
  85. Removes the module object created from *def* from the interpreter state.
  86. .. versionadded:: 3.3
  87. Initializing C modules
  88. ^^^^^^^^^^^^^^^^^^^^^^
  89. These functions are usually used in the module initialization function.
  90. .. c:function:: PyObject* PyModule_Create(PyModuleDef *module)
  91. Create a new module object, given the definition in *module*. This behaves
  92. like :c:func:`PyModule_Create2` with *module_api_version* set to
  93. :const:`PYTHON_API_VERSION`.
  94. .. c:function:: PyObject* PyModule_Create2(PyModuleDef *module, int module_api_version)
  95. Create a new module object, given the definition in *module*, assuming the
  96. API version *module_api_version*. If that version does not match the version
  97. of the running interpreter, a :exc:`RuntimeWarning` is emitted.
  98. .. note::
  99. Most uses of this function should be using :c:func:`PyModule_Create`
  100. instead; only use this if you are sure you need it.
  101. .. c:type:: PyModuleDef
  102. This struct holds all information that is needed to create a module object.
  103. There is usually only one static variable of that type for each module, which
  104. is statically initialized and then passed to :c:func:`PyModule_Create` in the
  105. module initialization function.
  106. .. c:member:: PyModuleDef_Base m_base
  107. Always initialize this member to :const:`PyModuleDef_HEAD_INIT`.
  108. .. c:member:: char* m_name
  109. Name for the new module.
  110. .. c:member:: char* m_doc
  111. Docstring for the module; usually a docstring variable created with
  112. :c:func:`PyDoc_STRVAR` is used.
  113. .. c:member:: Py_ssize_t m_size
  114. Some modules allow re-initialization (calling their ``PyInit_*`` function
  115. more than once). These modules should keep their state in a per-module
  116. memory area that can be retrieved with :c:func:`PyModule_GetState`.
  117. This memory should be used, rather than static globals, to hold per-module
  118. state, since it is then safe for use in multiple sub-interpreters. It is
  119. freed when the module object is deallocated, after the :c:member:`m_free`
  120. function has been called, if present.
  121. Setting ``m_size`` to ``-1`` means that the module can not be
  122. re-initialized because it has global state. Setting it to a non-negative
  123. value means that the module can be re-initialized and specifies the
  124. additional amount of memory it requires for its state.
  125. See :PEP:`3121` for more details.
  126. .. c:member:: PyMethodDef* m_methods
  127. A pointer to a table of module-level functions, described by
  128. :c:type:`PyMethodDef` values. Can be *NULL* if no functions are present.
  129. .. c:member:: inquiry m_reload
  130. Currently unused, should be *NULL*.
  131. .. c:member:: traverseproc m_traverse
  132. A traversal function to call during GC traversal of the module object, or
  133. *NULL* if not needed.
  134. .. c:member:: inquiry m_clear
  135. A clear function to call during GC clearing of the module object, or
  136. *NULL* if not needed.
  137. .. c:member:: freefunc m_free
  138. A function to call during deallocation of the module object, or *NULL* if
  139. not needed.
  140. .. c:function:: int PyModule_AddObject(PyObject *module, const char *name, PyObject *value)
  141. Add an object to *module* as *name*. This is a convenience function which can
  142. be used from the module's initialization function. This steals a reference to
  143. *value*. Return ``-1`` on error, ``0`` on success.
  144. .. c:function:: int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
  145. Add an integer constant to *module* as *name*. This convenience function can be
  146. used from the module's initialization function. Return ``-1`` on error, ``0`` on
  147. success.
  148. .. c:function:: int PyModule_AddStringConstant(PyObject *module, const char *name, const char *value)
  149. Add a string constant to *module* as *name*. This convenience function can be
  150. used from the module's initialization function. The string *value* must be
  151. null-terminated. Return ``-1`` on error, ``0`` on success.
  152. .. c:function:: int PyModule_AddIntMacro(PyObject *module, macro)
  153. Add an int constant to *module*. The name and the value are taken from
  154. *macro*. For example ``PyModule_AddIntMacro(module, AF_INET)`` adds the int
  155. constant *AF_INET* with the value of *AF_INET* to *module*.
  156. Return ``-1`` on error, ``0`` on success.
  157. .. c:function:: int PyModule_AddStringMacro(PyObject *module, macro)
  158. Add a string constant to *module*.