74 lines
3.2 KiB
Diff
74 lines
3.2 KiB
Diff
From d7b9d509458a0945d1d314b4d93fd2aaac30de96 Mon Sep 17 00:00:00 2001
|
|
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
|
|
Date: Tue, 15 Sep 2020 22:19:32 +0200
|
|
Subject: [PATCH 1/2] Fix several testing issues on m32 architectures
|
|
|
|
- Do not overflow using 2**32
|
|
- Be explicit about array type
|
|
|
|
This is a partial fix for #1639
|
|
---
|
|
pythran/tests/test_numpy_func0.py | 4 ++--
|
|
pythran/tests/test_numpy_func2.py | 2 +-
|
|
2 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/pythran/tests/test_numpy_func0.py b/pythran/tests/test_numpy_func0.py
|
|
index 0ab6f26cc..ed6c26285 100644
|
|
--- a/pythran/tests/test_numpy_func0.py
|
|
+++ b/pythran/tests/test_numpy_func0.py
|
|
@@ -420,7 +420,7 @@ def test_tofile1(self):
|
|
|
|
def test_tofile2(self):
|
|
temp_name = tempfile.mkstemp()[1]
|
|
- x = numpy.random.randint(0,2**32,1000).astype(numpy.uint32)
|
|
+ x = numpy.random.randint(0,2**31,1000).astype(numpy.uint32)
|
|
try:
|
|
self.run_test("def np_tofile2(x,file): import numpy ; x.tofile(file); return numpy.fromfile(file)", x, temp_name, np_tofile2=[NDArray[numpy.uint32,:], str])
|
|
finally:
|
|
@@ -462,7 +462,7 @@ def test_fromfile1(self):
|
|
|
|
def test_fromfile2(self):
|
|
temp_name = tempfile.mkstemp()[1]
|
|
- x = numpy.random.randint(0,2**32,1000).astype(numpy.uint32)
|
|
+ x = numpy.random.randint(0,2**31,1000).astype(numpy.uint32)
|
|
x.tofile(temp_name)
|
|
try:
|
|
self.run_test("def np_fromfile2(file): from numpy import fromfile, uint32 ; return fromfile(file, uint32)", temp_name, np_fromfile2=[str])
|
|
diff --git a/pythran/tests/test_numpy_func2.py b/pythran/tests/test_numpy_func2.py
|
|
index e378b6501..0ff090a55 100644
|
|
--- a/pythran/tests/test_numpy_func2.py
|
|
+++ b/pythran/tests/test_numpy_func2.py
|
|
@@ -491,7 +491,7 @@ def test_asarray4(self):
|
|
self.run_test("def np_asarray4(a):\n from numpy import asarray\n return asarray(a[1:])", [(1,2),(3,4)], np_asarray4=[List[Tuple[int, int]]])
|
|
|
|
def test_asarray5(self):
|
|
- self.run_test("def np_asarray5(a):\n from numpy import asarray\n return asarray(a)", 1, np_asarray5=[int])
|
|
+ self.run_test("def np_asarray5(a):\n from numpy import asarray\n return asarray(a)", 1., np_asarray5=[float])
|
|
|
|
def test_asarray6(self):
|
|
self.run_test("def np_asarray6(a):\n from numpy import asarray\n return asarray(a, dtype=int)", 1.5, np_asarray6=[float])
|
|
|
|
From f59b69c9f08bfb69c391bf3c4ddfa10e3612ac84 Mon Sep 17 00:00:00 2001
|
|
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
|
|
Date: Wed, 16 Sep 2020 09:47:17 +0200
|
|
Subject: [PATCH 2/2] Avoid overflow when comparing ranges
|
|
|
|
---
|
|
pythran/pythonic/builtins/range.hpp | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/pythran/pythonic/builtins/range.hpp b/pythran/pythonic/builtins/range.hpp
|
|
index 75ace78d1..3214ddbbe 100644
|
|
--- a/pythran/pythonic/builtins/range.hpp
|
|
+++ b/pythran/pythonic/builtins/range.hpp
|
|
@@ -64,7 +64,8 @@ namespace builtins
|
|
|
|
bool range_iterator::operator<(range_iterator const &other) const
|
|
{
|
|
- return step_ * value_ < step_ * other.value_;
|
|
+ const long sign = +1 | (step_ >> (sizeof(long) * CHAR_BIT - 1));
|
|
+ return sign * value_ < sign * other.value_;
|
|
}
|
|
|
|
long range_iterator::operator-(range_iterator const &other) const
|