mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
[3.12] gh-106033: Get rid of PyDict_GetItem in _PyFunction_FromConstructor (GH-106044) (GH-106228)
gh-106033: Get rid of PyDict_GetItem in _PyFunction_FromConstructor (GH-106044)
(cherry picked from commit 08c08d21b0
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
e12045d648
commit
e0fa531d7a
1 changed files with 6 additions and 4 deletions
|
@ -106,9 +106,14 @@ PyFunction_ClearWatcher(int watcher_id)
|
||||||
PyFunctionObject *
|
PyFunctionObject *
|
||||||
_PyFunction_FromConstructor(PyFrameConstructor *constr)
|
_PyFunction_FromConstructor(PyFrameConstructor *constr)
|
||||||
{
|
{
|
||||||
|
PyObject *module = Py_XNewRef(PyDict_GetItemWithError(constr->fc_globals, &_Py_ID(__name__)));
|
||||||
|
if (!module && PyErr_Occurred()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
PyFunctionObject *op = PyObject_GC_New(PyFunctionObject, &PyFunction_Type);
|
PyFunctionObject *op = PyObject_GC_New(PyFunctionObject, &PyFunction_Type);
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
|
Py_XDECREF(module);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
op->func_globals = Py_NewRef(constr->fc_globals);
|
op->func_globals = Py_NewRef(constr->fc_globals);
|
||||||
|
@ -122,10 +127,7 @@ _PyFunction_FromConstructor(PyFrameConstructor *constr)
|
||||||
op->func_doc = Py_NewRef(Py_None);
|
op->func_doc = Py_NewRef(Py_None);
|
||||||
op->func_dict = NULL;
|
op->func_dict = NULL;
|
||||||
op->func_weakreflist = NULL;
|
op->func_weakreflist = NULL;
|
||||||
op->func_module = Py_XNewRef(PyDict_GetItem(op->func_globals, &_Py_ID(__name__)));
|
op->func_module = module;
|
||||||
if (!op->func_module) {
|
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
op->func_annotations = NULL;
|
op->func_annotations = NULL;
|
||||||
op->func_typeparams = NULL;
|
op->func_typeparams = NULL;
|
||||||
op->vectorcall = _PyFunction_Vectorcall;
|
op->vectorcall = _PyFunction_Vectorcall;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue