diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2018-10-30 22:18:49 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2018-10-30 22:18:49 +0100 |
commit | 32370aa6eb31998b938de513bef680f3389472c5 (patch) | |
tree | c62dae21121454674ecfda74edbd5492fcb1f632 /Cython | |
parent | 70b6b3c938ca0336a37cb0413766c178454558d3 (diff) | |
parent | d774524e35aef599883361c515caa9446fa8adc2 (diff) | |
download | cython-32370aa6eb31998b938de513bef680f3389472c5.tar.gz |
Merge branch '0.29.x'
Diffstat (limited to 'Cython')
-rw-r--r-- | Cython/Compiler/ParseTreeTransforms.py | 4 | ||||
-rw-r--r-- | Cython/Utility/MemoryView_C.c | 46 |
2 files changed, 33 insertions, 17 deletions
diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index 9753a2f61..f4c0f5c36 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -1707,6 +1707,8 @@ if VALUE is not None: # so it can be pickled *after* self is memoized. unpickle_func = TreeFragment(u""" def %(unpickle_func_name)s(__pyx_type, long __pyx_checksum, __pyx_state): + cdef object __pyx_PickleError + cdef object __pyx_result if __pyx_checksum != %(checksum)s: from pickle import PickleError as __pyx_PickleError raise __pyx_PickleError("Incompatible checksums (%%s vs %(checksum)s = (%(members)s))" %% __pyx_checksum) @@ -1735,6 +1737,8 @@ if VALUE is not None: pickle_func = TreeFragment(u""" def __reduce_cython__(self): + cdef tuple state + cdef object _dict cdef bint use_setstate state = (%(members)s) _dict = getattr(self, '__dict__', None) diff --git a/Cython/Utility/MemoryView_C.c b/Cython/Utility/MemoryView_C.c index b7bd6a04e..5caf3a3ef 100644 --- a/Cython/Utility/MemoryView_C.c +++ b/Cython/Utility/MemoryView_C.c @@ -852,28 +852,40 @@ if (unlikely(__pyx_memoryview_slice_memviewslice( { Py_ssize_t __pyx_tmp_idx = {{idx}}; - Py_ssize_t __pyx_tmp_shape = {{src}}.shape[{{dim}}]; + + {{if wraparound or boundscheck}} + Py_ssize_t __pyx_tmp_shape = {{src}}.shape[{{dim}}]; + {{endif}} + Py_ssize_t __pyx_tmp_stride = {{src}}.strides[{{dim}}]; - if ({{wraparound}} && (__pyx_tmp_idx < 0)) - __pyx_tmp_idx += __pyx_tmp_shape; + {{if wraparound}} + if (__pyx_tmp_idx < 0) + __pyx_tmp_idx += __pyx_tmp_shape; + {{endif}} - if ({{boundscheck}} && !__Pyx_is_valid_index(__pyx_tmp_idx, __pyx_tmp_shape)) { - {{if not have_gil}} - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); - #endif - {{endif}} + {{if boundscheck}} + if (!__Pyx_is_valid_index(__pyx_tmp_idx, __pyx_tmp_shape)) { + {{if not have_gil}} + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); + #endif + {{endif}} - PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis {{dim}})"); + PyErr_SetString(PyExc_IndexError, + "Index out of bounds (axis {{dim}})"); - {{if not have_gil}} - #ifdef WITH_THREAD - PyGILState_Release(__pyx_gilstate_save); - #endif - {{endif}} + {{if not have_gil}} + #ifdef WITH_THREAD + PyGILState_Release(__pyx_gilstate_save); + #endif + {{endif}} - {{error_goto}} - } + {{error_goto}} + } + {{else}} + // make sure label is not un-used + if ((0)) {{error_goto}} + {{endif}} {{if all_dimensions_direct}} {{dst}}.data += __pyx_tmp_idx * __pyx_tmp_stride; |