[numpy] Add patch from github pull 371 to fix python 3.3 pickle issue Remove cython .c source regeneration -
Orion Poplawski
orion at fedoraproject.org
Thu Aug 23 04:21:11 UTC 2012
commit 0d2d06afa34fe6f92a9b28f01095d6b8c5c8cce4
Author: Orion Poplawski <orion at nwra.com>
Date: Wed Aug 22 22:21:14 2012 -0600
Add patch from github pull 371 to fix python 3.3 pickle issue
Remove cython .c source regeneration - fails now
numpy-pull371.patch | 33 +++++++++++++++++++++++++++++++++
numpy.spec | 24 ++++++++++--------------
2 files changed, 43 insertions(+), 14 deletions(-)
---
diff --git a/numpy-pull371.patch b/numpy-pull371.patch
new file mode 100644
index 0000000..231cf99
--- /dev/null
+++ b/numpy-pull371.patch
@@ -0,0 +1,33 @@
+diff -up numpy-1.7.0b1/numpy/core/src/multiarray/methods.c.pull371 numpy-1.7.0b1/numpy/core/src/multiarray/methods.c
+--- numpy-1.7.0b1/numpy/core/src/multiarray/methods.c.pull371 2012-08-12 21:53:17.000000000 -0600
++++ numpy-1.7.0b1/numpy/core/src/multiarray/methods.c 2012-08-22 22:07:17.287365026 -0600
+@@ -1587,8 +1587,9 @@ array_setstate(PyArrayObject *self, PyOb
+ /* Check that the string is not interned */
+ if (!_IsAligned(self) || swap || PyString_CHECK_INTERNED(rawdata)) {
+ #else
+- /* Bytes are never interned */
+- if (!_IsAligned(self) || swap) {
++ /* Bytes should always be considered immutable, but we just grab the
++ * pointer if they are large, to save memory. */
++ if (!_IsAligned(self) || swap || (len <= 1000)) {
+ #endif
+ npy_intp num = PyArray_NBYTES(self);
+ fa->data = PyDataMem_NEW(num);
+diff -up numpy-1.7.0b1/numpy/core/tests/test_regression.py.pull371 numpy-1.7.0b1/numpy/core/tests/test_regression.py
+--- numpy-1.7.0b1/numpy/core/tests/test_regression.py.pull371 2012-08-12 21:53:17.000000000 -0600
++++ numpy-1.7.0b1/numpy/core/tests/test_regression.py 2012-08-21 16:34:29.894303390 -0600
+@@ -1601,6 +1601,14 @@ class TestRegression(TestCase):
+ s = re.sub("a(.)", "\x01\\1", "a_")
+ assert_equal(s[0], "\x01")
+
++ def test_pickle_bytes_overwrite(self):
++ if sys.version_info[0] >= 3:
++ data = np.array([1], dtype='b')
++ data = pickle.loads(pickle.dumps(data))
++ data[0] = 0xdd
++ bytestring = "\x01 ".encode('ascii')
++ assert_equal(bytestring[0:1], '\x01'.encode('ascii'))
++
+ def test_structured_type_to_object(self):
+ a_rec = np.array([(0,1), (3,2)], dtype='i4,i8')
+ a_obj = np.empty((2,), dtype=object)
diff --git a/numpy.spec b/numpy.spec
index bfebabf..11cb3e1 100644
--- a/numpy.spec
+++ b/numpy.spec
@@ -9,7 +9,7 @@
Name: numpy
Version: 1.7.0
-Release: 0.2.%{relc}%{?dist}
+Release: 0.3.%{relc}%{?dist}
Epoch: 1
Summary: A fast multidimensional array facility for Python
@@ -34,6 +34,10 @@ Patch2: 002-fix_PyUnicodeObject.patch
# "FIX: Make sure the tests produce valid unicode"
# copy of upstream commit 4234b6b13e3ee9da6fc1c24e9e8c442d77587837:
Patch3: 4234b6b13e3ee9da6fc1c24e9e8c442d77587837.patch
+#
+# Copy bytes object when unpickling an array
+# https://github.com/numpy/numpy/pull/371
+Patch4: numpy-pull371.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -104,24 +108,12 @@ This package includes a version of f2py that works properly with NumPy.
%patch1 -p1
%patch2 -p1
%patch3 -p1
+%patch4 -p1 -b .pull371
# workaround for rhbz#849713
# http://mail.scipy.org/pipermail/numpy-discussion/2012-July/063530.html
rm numpy/distutils/command/__init__.py && touch numpy/distutils/command/__init__.py
-# Regenerate Cython c sources
-# This is needed with numpy-1.6.2.tar.gz with python 3.3 to avoid an exception
-# with an import call in the generated .c file in the tarball that uses the
-# old default of -1:
-# File "mtrand.pyx", line 126, in init mtrand (numpy/random/mtrand/mtrand.c:20679)
-# ValueError: level must be >= 0
-# due to the changes in import in 3.3
-# Regenerating with a newer Cython fixes it:
-pushd numpy/random/mtrand/
-rm -v mtrand.c
-cython mtrand.pyx
-popd
-
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
@@ -286,6 +278,10 @@ rm -rf %{buildroot}
%changelog
+* Wed Aug 22 2012 Orion Poplawski <orion at nwra.com> - 1:1.7.0-0.3.b1
+- Add patch from github pull 371 to fix python 3.3 pickle issue
+- Remove cython .c source regeneration - fails now
+
* Wed Aug 22 2012 Orion Poplawski <orion at nwra.com> - 1:1.7.0-0.2.b1
- add workaround for rhbz#849713 (fixes FTBFS)
More information about the scm-commits
mailing list