Commit 9789f14e authored by Stefan Behnel's avatar Stefan Behnel

moved DictGetItem utility code into ObjectHandling.c

parent 6d72f76e
...@@ -2916,7 +2916,8 @@ class IndexNode(ExprNode): ...@@ -2916,7 +2916,8 @@ class IndexNode(ExprNode):
index_code = self.index.py_result() index_code = self.index.py_result()
if self.base.type is dict_type: if self.base.type is dict_type:
function = "__Pyx_PyDict_GetItem" function = "__Pyx_PyDict_GetItem"
code.globalstate.use_utility_code(getitem_dict_utility_code) code.globalstate.use_utility_code(
UtilityCode.load_cached("DictGetItem", "ObjectHandling.c"))
else: else:
function = "PyObject_GetItem" function = "PyObject_GetItem"
code.putln( code.putln(
...@@ -9741,32 +9742,6 @@ requires = [raise_unbound_local_error_utility_code]) ...@@ -9741,32 +9742,6 @@ requires = [raise_unbound_local_error_utility_code])
#------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------
getitem_dict_utility_code = UtilityCode(
proto = """
#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
PyObject *value;
if (unlikely(d == Py_None)) {
__Pyx_RaiseNoneIndexingError();
return NULL;
}
value = PyDict_GetItemWithError(d, key);
if (unlikely(!value)) {
if (!PyErr_Occurred())
PyErr_SetObject(PyExc_KeyError, key);
return NULL;
}
Py_INCREF(value);
return value;
}
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif
""",
requires = [raise_noneindex_error_utility_code])
#------------------------------------------------------------------------------------
getitem_int_pyunicode_utility_code = UtilityCode( getitem_int_pyunicode_utility_code = UtilityCode(
proto = ''' proto = '''
#define __Pyx_GetItemInt_Unicode(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \\ #define __Pyx_GetItemInt_Unicode(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \\
......
...@@ -235,6 +235,29 @@ static CYTHON_INLINE int __Pyx_IterFinish(void) { ...@@ -235,6 +235,29 @@ static CYTHON_INLINE int __Pyx_IterFinish(void) {
#endif #endif
} }
/////////////// DictGetItem.proto ///////////////
//@requires: RaiseNoneIndexingError
#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
PyObject *value;
if (unlikely(d == Py_None)) {
__Pyx_RaiseNoneIndexingError();
return NULL;
}
value = PyDict_GetItemWithError(d, key);
if (unlikely(!value)) {
if (!PyErr_Occurred())
PyErr_SetObject(PyExc_KeyError, key);
return NULL;
}
Py_INCREF(value);
return value;
}
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif
/////////////// FindPy2Metaclass.proto /////////////// /////////////// FindPy2Metaclass.proto ///////////////
static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/ static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment