File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -106,9 +106,14 @@ PyFunction_ClearWatcher(int watcher_id)
106106PyFunctionObject *
107107_PyFunction_FromConstructor (PyFrameConstructor * constr )
108108{
109+ PyObject * module = Py_XNewRef (PyDict_GetItemWithError (constr -> fc_globals , & _Py_ID (__name__ )));
110+ if (!module && PyErr_Occurred ()) {
111+ return NULL ;
112+ }
109113
110114 PyFunctionObject * op = PyObject_GC_New (PyFunctionObject , & PyFunction_Type );
111115 if (op == NULL ) {
116+ Py_XDECREF (module );
112117 return NULL ;
113118 }
114119 op -> func_globals = Py_NewRef (constr -> fc_globals );
@@ -122,10 +127,7 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr)
122127 op -> func_doc = Py_NewRef (Py_None );
123128 op -> func_dict = NULL ;
124129 op -> func_weakreflist = NULL ;
125- op -> func_module = Py_XNewRef (PyDict_GetItem (op -> func_globals , & _Py_ID (__name__ )));
126- if (!op -> func_module ) {
127- PyErr_Clear ();
128- }
130+ op -> func_module = module ;
129131 op -> func_annotations = NULL ;
130132 op -> func_typeparams = NULL ;
131133 op -> vectorcall = _PyFunction_Vectorcall ;
You can’t perform that action at this time.
0 commit comments