aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-11-04 13:59:15 +0100
committerGitHub <noreply@github.com>2020-11-04 13:59:15 +0100
commit8021875bbcf7385e651def51bc597472a569042c (patch)
tree9309451fd98ae23460596a2f2cbc6d8b7f9e3395 /Include
parentbpo-42236: os.device_encoding() respects UTF-8 Mode (GH-23119) (diff)
downloadcpython-8021875bbcf7385e651def51bc597472a569042c.tar.gz
cpython-8021875bbcf7385e651def51bc597472a569042c.tar.bz2
cpython-8021875bbcf7385e651def51bc597472a569042c.zip
bpo-1635741: Add PyModule_AddObjectRef() function (GH-23122)
Added PyModule_AddObjectRef() function: similar to PyModule_AddObjectRef() but don't steal a reference to the value on success.
Diffstat (limited to 'Include')
-rw-r--r--Include/modsupport.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/Include/modsupport.h b/Include/modsupport.h
index 4c4aab65bac..f009d586bf6 100644
--- a/Include/modsupport.h
+++ b/Include/modsupport.h
@@ -136,7 +136,15 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
void _PyArg_Fini(void);
#endif /* Py_LIMITED_API */
-PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
+// Add an attribute with name 'name' and value 'obj' to the module 'mod.
+// On success, return 0 on success.
+// On error, raise an exception and return -1.
+PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value);
+
+// Similar to PyModule_AddObjectRef() but steal a reference to 'obj'
+// (Py_DECREF(obj)) on success (if it returns 0).
+PyAPI_FUNC(int) PyModule_AddObject(PyObject *mod, const char *, PyObject *value);
+
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000