Commit de12778f authored by Stefan Behnel's avatar Stefan Behnel

work around stupid C compiler warnings about tests being always true due to integer ranges

parent c9486f9b
......@@ -2,13 +2,16 @@
/* Type Conversion Predeclarations */
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \
(sizeof(type) < sizeof(Py_ssize_t)) || \
(sizeof(type) > sizeof(Py_ssize_t) && \
likely(v <= (type)PY_SSIZE_T_MAX) && \
(!is_signed || likely(v >= (type)PY_SSIZE_T_MIN))) || \
(sizeof(type) == sizeof(Py_ssize_t) && \
(is_signed || likely(v <= (type)PY_SSIZE_T_MAX))) )
#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \
(sizeof(type) < sizeof(Py_ssize_t)) || \
(sizeof(type) > sizeof(Py_ssize_t) && \
likely(v < (type)PY_SSIZE_T_MAX || \
v == (type)PY_SSIZE_T_MAX) && \
(!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \
v == (type)PY_SSIZE_T_MIN))) || \
(sizeof(type) == sizeof(Py_ssize_t) && \
(is_signed || likely(v < (type)PY_SSIZE_T_MAX || \
v == (type)PY_SSIZE_T_MAX))) )
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
......
......@@ -161,8 +161,58 @@ def test_long_long():
ix = (<long long>1) << i
assert D[ix] is True
del D[ix]
L = [1, 2, 3]
try:
ix = py_maxsize + 1
except OverflowError:
pass # can't test this here
else:
try: L[ix] = 5
except IndexError: pass
else: assert False, "setting large index failed to raise IndexError"
try: del L[ix]
except IndexError: pass
else: assert False, "deleting large index failed to raise IndexError"
try:
ix = -py_maxsize - 2
except OverflowError:
pass # can't test this here
else:
try: L[ix] = 5
except IndexError: pass
else: assert False, "setting large index failed to raise IndexError"
try: del L[ix]
except IndexError: pass
else: assert False, "deleting large index failed to raise IndexError"
assert len(D) == 0
def test_ulong_long():
"""
>>> test_ulong_long()
"""
cdef unsigned long long ix
L = [1, 2, 3]
try:
ix = py_maxsize + 1
except OverflowError:
pass # can't test this here
else:
try: L[ix] = 5
except IndexError: pass
else: assert False, "setting large index failed to raise IndexError"
try: del L[ix]
except IndexError: pass
else: assert False, "deleting large index failed to raise IndexError"
@cython.boundscheck(False)
def test_boundscheck_unsigned(list L, tuple t, object o, unsigned long ix):
"""
......
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