aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Modules
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2025-04-28 20:12:52 -0600
committerGitHub <noreply@github.com>2025-04-28 20:12:52 -0600
commit96a7fb93a8e31eae368b9efee945f6959355e8ba (patch)
tree48528047d90971178c503d4da7badc8bbf28457d /Modules
parent75cbb8d89e7e92ccaba5c615c72459f241dca8b1 (diff)
downloadcpython-96a7fb93a8e31eae368b9efee945f6959355e8ba.tar.gz
cpython-96a7fb93a8e31eae368b9efee945f6959355e8ba.zip
gh-132775: Add _PyCode_ReturnsOnlyNone() (gh-132981)
The function indicates whether or not the function has a return statement. This is used by a later change related treating some functions like scripts.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testinternalcapi.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 0ef064fe80d..4415a333452 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -946,6 +946,18 @@ iframe_getlasti(PyObject *self, PyObject *frame)
}
static PyObject *
+code_returns_only_none(PyObject *self, PyObject *arg)
+{
+ if (!PyCode_Check(arg)) {
+ PyErr_SetString(PyExc_TypeError, "argument must be a code object");
+ return NULL;
+ }
+ PyCodeObject *code = (PyCodeObject *)arg;
+ int res = _PyCode_ReturnsOnlyNone(code);
+ return PyBool_FromLong(res);
+}
+
+static PyObject *
get_co_framesize(PyObject *self, PyObject *arg)
{
if (!PyCode_Check(arg)) {
@@ -2074,6 +2086,7 @@ static PyMethodDef module_functions[] = {
{"iframe_getcode", iframe_getcode, METH_O, NULL},
{"iframe_getline", iframe_getline, METH_O, NULL},
{"iframe_getlasti", iframe_getlasti, METH_O, NULL},
+ {"code_returns_only_none", code_returns_only_none, METH_O, NULL},
{"get_co_framesize", get_co_framesize, METH_O, NULL},
{"jit_enabled", jit_enabled, METH_NOARGS, NULL},
#ifdef _Py_TIER2