Commit 32370aa6 authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.29.x'

parents 70b6b3c9 d774524e
......@@ -28,9 +28,24 @@ Other changes
Bugs fixed
----------
* Extensions compiled with MinGW-64 under Windows could misinterpret integer
objects larger than 15 bit and return incorrect results.
(Github issue #2670)
* Line tracing of ``try``-statements generated invalid C code.
(Github issue #2274)
* When using the ``warn.undeclared`` directive, Cython's own code generated
warnings that are now fixed.
Patch by Nicolas Pauss. (Github issue #2685)
* Some C compiler warnings about unused memoryview code were fixed.
Patch by Ho Cheuk Ting. (Github issue #2588)
* Signatures with memory view arguments now show the expected type
when embedded in docstrings.
Patch by Matthew Chan and Benjamin Weigel. (Github issue #2634)
0.29 (2018-10-14)
=================
......
......@@ -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)
......
......@@ -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;
......
# cython: warn.undeclared=True
# mode: error
# tag: werror
def foo():
a = 1
return a
cdef class Bar:
cdef int baz(self, a):
res = 0
for i in range(3):
res += i
return res
_ERRORS = """
6:4: implicit declaration of 'a'
11:8: implicit declaration of 'res'
12:12: implicit declaration of 'i'
"""
......@@ -370,6 +370,7 @@ def test_coerce_to_numpy():
ints[idx] = 222
longlongs[idx] = 333
externs[idx] = 444
assert externs[idx] == 444 # avoid "set but not used" C compiler warning
floats[idx] = 11.1
doubles[idx] = 12.2
......@@ -699,3 +700,21 @@ def test_refcount_GH507():
a = np.arange(12).reshape([3, 4])
cdef np.int_t[:,:] a_view = a
cdef np.int_t[:,:] b = a_view[1:2,:].T
@cython.boundscheck(False)
@cython.wraparound(False)
def test_boundscheck_and_wraparound(double[:, :] x):
"""
>>> import numpy as np
>>> array = np.ones((2,2)) * 3.5
>>> testing_memoryview(array)
"""
# Make sure we don't generate C compiler warnings for unused code here.
cdef Py_ssize_t numrow = x.shape[0]
cdef Py_ssize_t i
for i in range(numrow):
x[i, 0]
x[i]
x[i, ...]
x[i, :]
# mode: run
__doc__ = u"""
>>> int2 = 42
>>> int3 = 7
......@@ -35,3 +37,24 @@ def f():
int1 ^= int2 << int3 | int2 >> int3
long1 = char1 | int1
return int1, long1
def long_int_shift():
"""
>>> long_int_shift()
80082
10010
10010
10010
10010
"""
value = 80082 # int using more than 2 bytes == long
print(value)
shiftedby3 = value >> 3
dividedby8 = value // 8
print(shiftedby3)
print(dividedby8)
shiftedby3 = 80082 >> 3
dividedby8 = 80082 // 8
print(shiftedby3)
print(dividedby8)
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