static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) PyErr_SetObject(PyExc_KeyError, key); return NULL; } Py_INCREF(value); return value; }
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) PyErr_SetObject(PyExc_KeyError, args); Py_XDECREF(args); } return NULL; } Py_INCREF(value); return value; }
static PyObject * Struct_getattr(PyObject *self, PyObject *name) { PyObject *value; value = PyDict_GetItemWithError(self, name); if (value) { Py_INCREF(value); } else { if (PyErr_Occurred()) return NULL; value = PyObject_GenericGetAttr(self, name); if (value == NULL) { /* Look up __missing__ method if we're not the direct dict subclass */ if (!(Py_TYPE(self)->tp_base == &PyDict_Type)) { PyObject *missing, *res; PyObject *err_type, *err_value, *err_tb; PyErr_Fetch(&err_type, &err_value, &err_tb); #if PY_MAJOR_VERSION >= 3 _Py_IDENTIFIER(__missing__); missing = _PyObject_LookupSpecial(self, &PyId___missing__); #else static PyObject *missing_str = NULL; missing = _PyObject_LookupSpecial(self, "__missing__", &missing_str); #endif if (missing != NULL) { res = PyObject_CallFunctionObjArgs(missing, name, NULL); Py_DECREF(missing); return res; } else if (PyErr_Occurred()) return NULL; PyErr_Restore(err_type, err_value, err_tb); } } } return value; }
PyObject * PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname) { PyFunctionObject *op; PyObject *doc, *consts, *module; static PyObject *__name__ = NULL; if (__name__ == NULL) { __name__ = PyUnicode_InternFromString("__name__"); if (__name__ == NULL) return NULL; } op = PyObject_GC_New(PyFunctionObject, &PyFunction_Type); if (op == NULL) return NULL; op->func_weakreflist = NULL; Py_INCREF(code); op->func_code = code; Py_INCREF(globals); op->func_globals = globals; op->func_name = ((PyCodeObject *)code)->co_name; Py_INCREF(op->func_name); op->func_defaults = NULL; /* No default arguments */ op->func_kwdefaults = NULL; /* No keyword only defaults */ op->func_closure = NULL; consts = ((PyCodeObject *)code)->co_consts; if (PyTuple_Size(consts) >= 1) { doc = PyTuple_GetItem(consts, 0); if (!PyUnicode_Check(doc)) doc = Py_None; } else doc = Py_None; Py_INCREF(doc); op->func_doc = doc; op->func_dict = NULL; op->func_module = NULL; op->func_annotations = NULL; /* __module__: If module name is in globals, use it. Otherwise, use None. */ module = PyDict_GetItemWithError(globals, __name__); if (module) { Py_INCREF(module); op->func_module = module; } else if (PyErr_Occurred()) { Py_DECREF(op); return NULL; } if (qualname) op->func_qualname = qualname; else op->func_qualname = op->func_name; Py_INCREF(op->func_qualname); _PyObject_GC_TRACK(op); return (PyObject *)op; }