Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-numpy for openSUSE:Factory 
checked in at 2021-07-21 19:05:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-numpy (Old)
 and      /work/SRC/openSUSE:Factory/.python-numpy.new.2632 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-numpy"

Wed Jul 21 19:05:29 2021 rev:102 rq:906772 version:1.21.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-numpy/python-numpy.changes        
2021-07-10 22:54:18.975844783 +0200
+++ /work/SRC/openSUSE:Factory/.python-numpy.new.2632/python-numpy.changes      
2021-07-21 19:05:31.835202924 +0200
@@ -1,0 +2,8 @@
+Fri Jul 16 15:14:36 UTC 2021 - Ben Greiner <c...@bnavigator.de>
+
+- Fix segfault with subarray access
+  * Add numpy-pr19326-fix-subarray-segfault.patch
+  * Fixes python-zarr segfault
+  * gh#numpy/numpy#19326
+
+-------------------------------------------------------------------

New:
----
  numpy-pr19326-fix-subarray-segfault.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-numpy.spec ++++++
--- /var/tmp/diff_new_pack.yXpVs6/_old  2021-07-21 19:05:32.563204189 +0200
+++ /var/tmp/diff_new_pack.yXpVs6/_new  2021-07-21 19:05:32.567204197 +0200
@@ -79,6 +79,8 @@
 Patch1:         numpy-1.9.0-remove-__declspec.patch
 # PATCH-FIX-UPSTREAM 0001-BUG-Fix-infinite-loop-on-gcc11.patch
 Patch2:         0001-BUG-Fix-infinite-loop-on-gcc11.patch
+# PATCH-FIX-UPSTREAM numpy-pr19326-fix-subarray-segfault.patch -- 
gh#numpy/numpy#19326
+Patch3:         
https://github.com/numpy/numpy/pull/19326.patch#/numpy-pr19326-fix-subarray-segfault.patch
 BuildRequires:  %{python_module Cython >= 0.29.23}
 BuildRequires:  %{python_module base >= 3.7}
 BuildRequires:  %{python_module devel}
@@ -159,10 +161,7 @@
 %{?with_hpc:%{hpc_python_master_package devel -a }}
 
 %prep
-%setup -q -n numpy-%{version}
-%patch0 -p1
-%patch1 -p1
-%patch2 -p1
+%autosetup -p1 -n numpy-%{version}
 # Fix non-executable scripts
 sed -i '1s/^#!.*$//' 
numpy/{compat/setup,random/_examples/cython/setup,distutils/{conv_template,cpuinfo,exec_command,from_template,setup,system_info},f2py/{__init__,auxfuncs,capi_maps,cb_rules,cfuncs,common_rules,crackfortran,diagnose,f2py2e,f90mod_rules,func2subr,rules,setup,use_rules},ma/{setup,bench},matrixlib/setup,setup,testing/{print_coercion_tables,setup}}.py
 sed -i '1s/^#!.*$//' numpy/random/_examples/cython/*.pyx


++++++ numpy-pr19326-fix-subarray-segfault.patch ++++++
>From be09bb6ba4d27fbd1f667d34bb2f11cccb446d65 Mon Sep 17 00:00:00 2001
From: Gregory Lee <grle...@gmail.com>
Date: Thu, 24 Jun 2021 08:37:01 -0400
Subject: [PATCH 1/4] BUG: protect against access an attribute of a NULL
 pointer

Have PyArray_GetCastSafety return -1 if from is NULL
---
 numpy/core/src/multiarray/convert_datatype.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/numpy/core/src/multiarray/convert_datatype.c 
b/numpy/core/src/multiarray/convert_datatype.c
index d197a4bea31..716e5dd3d11 100644
--- a/numpy/core/src/multiarray/convert_datatype.c
+++ b/numpy/core/src/multiarray/convert_datatype.c
@@ -417,6 +417,9 @@ PyArray_GetCastSafety(
     if (to != NULL) {
         to_dtype = NPY_DTYPE(to);
     }
+    if (from == NULL) {
+        return -1;
+    }
     PyObject *meth = PyArray_GetCastingImpl(NPY_DTYPE(from), to_dtype);
     if (meth == NULL) {
         return -1;
@@ -3293,8 +3296,10 @@ void_to_void_resolve_descriptors(
                 casting = NPY_NO_CASTING | _NPY_CAST_IS_VIEW;
             }
         }
-        NPY_CASTING field_casting = PyArray_GetCastSafety(
-                given_descrs[0]->subarray->base, 
given_descrs[1]->subarray->base, NULL);
+
+        PyArray_Descr *from_base = (from_sub == NULL) ? NULL : from_sub->base;
+        PyArray_Descr *to_base = (to_sub == NULL) ? NULL : to_sub->base;
+        NPY_CASTING field_casting = PyArray_GetCastSafety(from_base, to_base, 
NULL);
         if (field_casting < 0) {
             return -1;
         }

>From 3c901b49bd8715c93824c27682d81434d869498a Mon Sep 17 00:00:00 2001
From: Gregory Lee <grle...@gmail.com>
Date: Thu, 24 Jun 2021 11:16:22 -0400
Subject: [PATCH 2/4] pass descriptor rather than null

---
 numpy/core/src/multiarray/convert_datatype.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/numpy/core/src/multiarray/convert_datatype.c 
b/numpy/core/src/multiarray/convert_datatype.c
index 716e5dd3d11..1bba276d2d1 100644
--- a/numpy/core/src/multiarray/convert_datatype.c
+++ b/numpy/core/src/multiarray/convert_datatype.c
@@ -417,9 +417,6 @@ PyArray_GetCastSafety(
     if (to != NULL) {
         to_dtype = NPY_DTYPE(to);
     }
-    if (from == NULL) {
-        return -1;
-    }
     PyObject *meth = PyArray_GetCastingImpl(NPY_DTYPE(from), to_dtype);
     if (meth == NULL) {
         return -1;
@@ -3297,8 +3294,8 @@ void_to_void_resolve_descriptors(
             }
         }
 
-        PyArray_Descr *from_base = (from_sub == NULL) ? NULL : from_sub->base;
-        PyArray_Descr *to_base = (to_sub == NULL) ? NULL : to_sub->base;
+        PyArray_Descr *from_base = (from_sub == NULL) ? given_descrs[0] : 
from_sub->base;
+        PyArray_Descr *to_base = (to_sub == NULL) ? given_descrs[1] : 
to_sub->base;
         NPY_CASTING field_casting = PyArray_GetCastSafety(from_base, to_base, 
NULL);
         if (field_casting < 0) {
             return -1;

>From 8925fec4721b3a89e94d59b6149884d07fc581f4 Mon Sep 17 00:00:00 2001
From: Gregory Lee <grle...@gmail.com>
Date: Thu, 24 Jun 2021 11:44:37 -0400
Subject: [PATCH 3/4] TST: test can_cast when only one argument has a subarray

---
 numpy/core/tests/test_casting_unittests.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/numpy/core/tests/test_casting_unittests.py 
b/numpy/core/tests/test_casting_unittests.py
index 2cec1acd349..34f316d5ddc 100644
--- a/numpy/core/tests/test_casting_unittests.py
+++ b/numpy/core/tests/test_casting_unittests.py
@@ -646,3 +646,9 @@ def test_object_to_parametric_internal_error(self):
         with pytest.raises(TypeError,
                     match="casting from object to the parametric DType"):
             cast._resolve_descriptors((np.dtype("O"), None))
+
+    def test_void_to_structured_with_subarray(self):
+        # test case corresponding to gh-19325
+        dtype = np.dtype([("foo", "<f4", (3, 2))])
+        assert np.can_cast("V4", dtype, casting="unsafe")
+        assert not np.can_cast("V4", dtype, casting="no")

>From 9bf60f5f8c5d0dde78b737932e61dec61b960d53 Mon Sep 17 00:00:00 2001
From: Gregory Lee <grle...@gmail.com>
Date: Thu, 24 Jun 2021 13:41:03 -0400
Subject: [PATCH 4/4] TST: test both argument orders

---
 numpy/core/tests/test_casting_unittests.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/numpy/core/tests/test_casting_unittests.py 
b/numpy/core/tests/test_casting_unittests.py
index 34f316d5ddc..d1924c1fda1 100644
--- a/numpy/core/tests/test_casting_unittests.py
+++ b/numpy/core/tests/test_casting_unittests.py
@@ -647,8 +647,10 @@ def test_object_to_parametric_internal_error(self):
                     match="casting from object to the parametric DType"):
             cast._resolve_descriptors((np.dtype("O"), None))
 
-    def test_void_to_structured_with_subarray(self):
+    @pytest.mark.parametrize("casting", ["no", "unsafe"])
+    def test_void_and_structured_with_subarray(self, casting):
         # test case corresponding to gh-19325
         dtype = np.dtype([("foo", "<f4", (3, 2))])
-        assert np.can_cast("V4", dtype, casting="unsafe")
-        assert not np.can_cast("V4", dtype, casting="no")
+        expected = casting == "unsafe"
+        assert np.can_cast("V4", dtype, casting=casting) == expected
+        assert np.can_cast(dtype, "V4", casting=casting) == expected

Reply via email to