aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 887a916563a..ac343a8048e 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2384,10 +2384,11 @@ sys__getframemodulename_impl(PyObject *module, int depth)
while (f && (_PyFrame_IsIncomplete(f) || depth-- > 0)) {
f = f->previous;
}
- if (f == NULL || f->f_funcobj == NULL) {
+ if (f == NULL || PyStackRef_IsNull(f->f_funcobj)) {
Py_RETURN_NONE;
}
- PyObject *r = PyFunction_GetModule(f->f_funcobj);
+ PyObject *func = PyStackRef_AsPyObjectBorrow(f->f_funcobj);
+ PyObject *r = PyFunction_GetModule(func);
if (!r) {
PyErr_Clear();
r = Py_None;