1
0
forked from pool/python-Cython
Files
python-Cython/fix-32bit.patch
Michal Čihař 4cbbcbaf4f Accepting request 298594 from home:Nijel:branches:devel:languages:python
- Add python-numpy as BuildRequires to have more complete test coverage

- Fix doctests in 32-bit environment (fix-32bit.patch)

- Update to 0.22:
  Features added
  * C functions can coerce to Python functions, which allows passing them
    around as callable objects.
  * C arrays can be assigned by value and auto-coerce from Python iterables
    and to Python lists (and tuples).
  * Extern C functions can now be declared as cpdef to export them to
    the module's Python namespace.  Extern C functions in pxd files export
    their values to their own module, iff it exists.
  * Anonymous C tuple types can be declared as (ctype1, ctype2, ...).
  * PEP 479: turn accidental StopIteration exceptions that exit generators
    into a RuntimeError, activated with future import "generator_stop".
    See http://legacy.python.org/dev/peps/pep-0479/
  * Looping over ``reversed(range())`` is optimised in the same way as
    ``range()``.  Patch by Favian Contreras.
  Bugs fixed
  * Mismatching 'except' declarations on signatures in .pxd and .pyx files failed
    to produce a compile error.
  * Failure to find any files for the path pattern(s) passed into ``cythonize()``
    is now an error to more easily detect accidental typos.
  * The ``logaddexp`` family of functions in ``numpy.math`` now has correct
    declarations.
  * In Py2.6/7 and Py3.2, simple Cython memory views could accidentally be
    interpreted as non-contiguous by CPython, which could trigger a CPython
    bug when copying data from them, thus leading to data corruption.
    See CPython issues 12834 and 23349.

OBS-URL: https://build.opensuse.org/request/show/298594
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Cython?expand=0&rev=56
2015-04-22 13:54:51 +00:00

123 lines
3.5 KiB
Diff

From 65408e6c70074c4fec128805888d18c7e933895a Mon Sep 17 00:00:00 2001
From: Stefan Behnel <stefan_ml@behnel.de>
Date: Fri, 13 Feb 2015 14:38:32 +0100
Subject: [PATCH] fix doctests in 32bit Py2.x
---
tests/run/carray_coercion.pyx | 23 +++++++++++++++++++----
tests/run/reversed_iteration.pyx | 35 +++++++++++++++++++++++------------
2 files changed, 42 insertions(+), 16 deletions(-)
diff --git a/tests/run/carray_coercion.pyx b/tests/run/carray_coercion.pyx
index d73fcf4..f04f820 100644
--- a/tests/run/carray_coercion.pyx
+++ b/tests/run/carray_coercion.pyx
@@ -1,3 +1,18 @@
+# mode: run
+
+import sys
+IS_PY3 = sys.version_info[0] >= 3
+IS_32BIT_PY2 = not IS_PY3 and sys.maxint < 2**32
+
+
+def unlongify(v):
+ # on 32bit Py2.x platforms, 'unsigned int' coerces to a Python long => fix doctest output here.
+ s = repr(v)
+ if IS_32BIT_PY2:
+ assert s.count('L') == s.count(',') + 1, s
+ s = s.replace('L', '')
+ return s
+
def from_int_array():
"""
@@ -30,8 +45,8 @@ cdef extern from "stdint.h":
def from_typedef_int_array():
"""
- >>> from_typedef_int_array()
- [1, 2, 3]
+ >>> unlongify(from_typedef_int_array())
+ '[1, 2, 3]'
"""
cdef uint32_t[3] v
v[0] = 1
@@ -42,8 +57,8 @@ def from_typedef_int_array():
cpdef tuple tuple_from_typedef_int_array():
"""
- >>> tuple_from_typedef_int_array()
- (1, 2, 3)
+ >>> unlongify(tuple_from_typedef_int_array())
+ '(1, 2, 3)'
"""
cdef uint32_t[3] v
v[0] = 1
diff --git a/tests/run/reversed_iteration.pyx b/tests/run/reversed_iteration.pyx
index 585d0df..0f55060 100644
--- a/tests/run/reversed_iteration.pyx
+++ b/tests/run/reversed_iteration.pyx
@@ -5,6 +5,17 @@ cimport cython
import sys
IS_PY3 = sys.version_info[0] >= 3
+IS_32BIT_PY2 = not IS_PY3 and sys.maxint < 2**32
+
+
+def unlongify(v):
+ # on 32bit Py2.x platforms, 'unsigned int' coerces to a Python long => fix doctest output here.
+ s = repr(v)
+ if IS_32BIT_PY2:
+ assert s.count('L') == s.count(',') + 1, s
+ s = s.replace('L', '')
+ return s
+
def _reversed(it):
return list(it)[::-1]
@@ -764,10 +775,10 @@ def reversed_bytes_slice_step_only(bytes s):
@cython.test_assert_path_exists('//ForFromStatNode')
def reversed_unsigned(int a, int b):
"""
- >>> reversed_unsigned(0, 5)
- [4, 3, 2, 1, 0]
- >>> reversed_unsigned(1, 5)
- [4, 3, 2, 1]
+ >>> unlongify(reversed_unsigned(0, 5))
+ '[4, 3, 2, 1, 0]'
+ >>> unlongify(reversed_unsigned(1, 5))
+ '[4, 3, 2, 1]'
>>> reversed_unsigned(1, 1)
[]
"""
@@ -777,10 +788,10 @@ def reversed_unsigned(int a, int b):
@cython.test_assert_path_exists('//ForFromStatNode')
def reversed_unsigned_by_3(int a, int b):
"""
- >>> reversed_unsigned_by_3(0, 5)
- [3, 0]
- >>> reversed_unsigned_by_3(0, 7)
- [6, 3, 0]
+ >>> unlongify(reversed_unsigned_by_3(0, 5))
+ '[3, 0]'
+ >>> unlongify(reversed_unsigned_by_3(0, 7))
+ '[6, 3, 0]'
"""
cdef unsigned int i
return [i for i in reversed(range(a, b, 3))]
@@ -788,10 +799,10 @@ def reversed_unsigned_by_3(int a, int b):
@cython.test_assert_path_exists('//ForFromStatNode')
def range_unsigned_by_neg_3(int a, int b):
"""
- >>> range_unsigned_by_neg_3(-1, 6)
- [6, 3, 0]
- >>> range_unsigned_by_neg_3(0, 7)
- [7, 4, 1]
+ >>> unlongify(range_unsigned_by_neg_3(-1, 6))
+ '[6, 3, 0]'
+ >>> unlongify(range_unsigned_by_neg_3(0, 7))
+ '[7, 4, 1]'
"""
cdef unsigned int i
return [i for i in range(b, a, -3)]