summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2023-01-13 11:31:06 (GMT)
committerGitHub <noreply@github.com>2023-01-13 11:31:06 (GMT)
commitb5d4347950399800c6703736d716f08761b29245 (patch)
treebb838154108d6740e062cd5b3d0756fd1a4f2d89 /Objects
parent94fc7706b7bc3d57cdd6d15bf8e8c4499ae53a69 (diff)
downloadcpython-b5d4347950399800c6703736d716f08761b29245.zip
cpython-b5d4347950399800c6703736d716f08761b29245.tar.gz
cpython-b5d4347950399800c6703736d716f08761b29245.tar.bz2
gh-86682: Adds sys._getframemodulename as an alternative to using _getframe (GH-99520)
Also updates calls in collections, doctest, enum, and typing modules to use _getframemodulename first when available.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/funcobject.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index d5cf5b9..baa3603 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -93,7 +93,10 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr)
op->func_doc = Py_NewRef(Py_None);
op->func_dict = NULL;
op->func_weakreflist = NULL;
- op->func_module = NULL;
+ op->func_module = Py_XNewRef(PyDict_GetItem(op->func_globals, &_Py_ID(__name__)));
+ if (!op->func_module) {
+ PyErr_Clear();
+ }
op->func_annotations = NULL;
op->vectorcall = _PyFunction_Vectorcall;
op->func_version = 0;