From e023b8835c5d7da2cfaa05bd8891d8697ba8655b Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 24 Oct 2025 11:42:41 +0200 Subject: [PATCH] Document that PyModule_GetDef can return NULL with or without setting an exception --- Doc/c-api/module.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 29d5cd8d5391a3..6626f628fcc47f 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -102,6 +102,10 @@ Module Objects Return a pointer to the :c:type:`PyModuleDef` struct from which the module was created, or ``NULL`` if the module wasn't created from a definition. + On error, return ``NULL`` with an exception set. + Use :c:func:`PyErr_Occurred` to tell this case apart from a mising + :c:type:`!PyModuleDef`. + .. c:function:: PyObject* PyModule_GetFilenameObject(PyObject *module)