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)
106
106
PyFunctionObject *
107
107
_PyFunction_FromConstructor (PyFrameConstructor * constr )
108
108
{
109
+ PyObject * module = Py_XNewRef (PyDict_GetItemWithError (constr -> fc_globals , & _Py_ID (__name__ )));
110
+ if (!module && PyErr_Occurred ()) {
111
+ return NULL ;
112
+ }
109
113
110
114
PyFunctionObject * op = PyObject_GC_New (PyFunctionObject , & PyFunction_Type );
111
115
if (op == NULL ) {
116
+ Py_XDECREF (module );
112
117
return NULL ;
113
118
}
114
119
op -> func_globals = Py_NewRef (constr -> fc_globals );
@@ -122,10 +127,7 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr)
122
127
op -> func_doc = Py_NewRef (Py_None );
123
128
op -> func_dict = NULL ;
124
129
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 ;
129
131
op -> func_annotations = NULL ;
130
132
op -> func_typeparams = NULL ;
131
133
op -> vectorcall = _PyFunction_Vectorcall ;
You can’t perform that action at this time.
0 commit comments