summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/module.rst
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-22 15:25:18 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-01-22 15:25:18 (GMT)
commit74b8e76ec1d85feacaa5e96b60a9c7f21026508f (patch)
tree07b20fdd26c0d2f54bb4d8ea3fef22658542b44b /Doc/c-api/module.rst
parent690c91220e06b6e3214c8a8efc214db276967b09 (diff)
downloadcpython-74b8e76ec1d85feacaa5e96b60a9c7f21026508f.zip
cpython-74b8e76ec1d85feacaa5e96b60a9c7f21026508f.tar.gz
cpython-74b8e76ec1d85feacaa5e96b60a9c7f21026508f.tar.bz2
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)
Diffstat (limited to 'Doc/c-api/module.rst')
-rw-r--r--Doc/c-api/module.rst20
1 files changed, 18 insertions, 2 deletions
diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst
index 064c365..4008d1a 100644
--- a/Doc/c-api/module.rst
+++ b/Doc/c-api/module.rst
@@ -18,7 +18,7 @@ There are only a few functions special to module objects.
is exposed to Python programs as ``types.ModuleType``.
-.. cfunction:: int PyModule_Check(PyObject *p)
+.. cmacro:: int PyModule_Check(PyObject *p)
Return true if *p* is a module object, or a subtype of a module object.
@@ -26,7 +26,7 @@ There are only a few functions special to module objects.
Allowed subtypes to be accepted.
-.. cfunction:: int PyModule_CheckExact(PyObject *p)
+.. cmacro:: int PyModule_CheckExact(PyObject *p)
Return true if *p* is a module object, but not a subtype of
:cdata:`PyModule_Type`.
@@ -103,3 +103,19 @@ There are only a few functions special to module objects.
null-terminated. Return ``-1`` on error, ``0`` on success.
.. versionadded:: 2.0
+
+.. cmacro:: int PyModule_AddIntMacro(PyObject *module, macro)
+
+ Add an int constant to *module*. The name and the value are taken from
+ *macro*. For example ``PyModule_AddConstant(module, AF_INET)`` adds the int
+ constant *AF_INET* with the value of *AF_INET* to *module*.
+ Return ``-1`` on error, ``0`` on success.
+
+ .. versionadded:: 2.6
+
+.. cmacro:: int PyModule_AddStringMacro(PyObject *module, macro)
+
+ Add a string constant to *module*.
+
+ .. versionadded:: 2.6
+