Commit f8081285 authored by Stefan Behnel's avatar Stefan Behnel

fix slicing in PyPy

parent 042ff575
...@@ -474,6 +474,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice( ...@@ -474,6 +474,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
{{endif}} {{endif}}
PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
#if CYTHON_COMPILING_IN_CPYTHON
PyMappingMethods* mp; PyMappingMethods* mp;
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
...@@ -521,12 +522,13 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice( ...@@ -521,12 +522,13 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
mp = Py_TYPE(obj)->tp_as_mapping; mp = Py_TYPE(obj)->tp_as_mapping;
{{if access == 'Get'}} {{if access == 'Get'}}
if (likely(mp && mp->mp_subscript)) { if (likely(mp && mp->mp_subscript))
PyObject *result;
{{else}} {{else}}
if (likely(mp && mp->mp_ass_subscript)) { if (likely(mp && mp->mp_ass_subscript))
int result;
{{endif}} {{endif}}
#endif
{
{{if access == 'Get'}}PyObject*{{else}}int{{endif}} result;
PyObject *py_slice, *py_start, *py_stop; PyObject *py_slice, *py_start, *py_stop;
if (_py_slice) { if (_py_slice) {
py_slice = *_py_slice; py_slice = *_py_slice;
...@@ -559,11 +561,17 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice( ...@@ -559,11 +561,17 @@ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(
Py_XDECREF(owned_stop); Py_XDECREF(owned_stop);
if (unlikely(!py_slice)) goto bad; if (unlikely(!py_slice)) goto bad;
} }
#if CYTHON_COMPILING_IN_CPYTHON
{{if access == 'Get'}} {{if access == 'Get'}}
result = mp->mp_subscript(obj, py_slice); result = mp->mp_subscript(obj, py_slice);
#else
result = PyObject_GetItem(obj, py_slice);
{{else}} {{else}}
result = mp->mp_ass_subscript(obj, py_slice, value); result = mp->mp_ass_subscript(obj, py_slice, value);
#else
result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice);
{{endif}} {{endif}}
#endif
if (!_py_slice) { if (!_py_slice) {
Py_DECREF(py_slice); Py_DECREF(py_slice);
} }
......
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