Compare commits
10 Commits
b8111500e2
...
fd352a1771
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd352a1771 | ||
|
|
10b683952f | ||
|
|
042b236b8a | ||
|
|
501364c8d2 | ||
|
|
556a17e105 | ||
|
|
f19c841087 | ||
|
|
088928ad1f | ||
|
|
656380ece8 | ||
|
|
0be317f2b8 | ||
|
|
70acecc715 |
277
adapted-cython3_noexcept.patch
Normal file
277
adapted-cython3_noexcept.patch
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
From 60720ee4d160fc2ae8ed74f98668f486ad862cef Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stefan Behnel <stefan_ml@behnel.de>
|
||||||
|
Date: Thu, 4 May 2023 09:18:16 +0200
|
||||||
|
Subject: [PATCH] Add "noexcept" markers to functions that do not raise
|
||||||
|
exceptions
|
||||||
|
|
||||||
|
---
|
||||||
|
numpy/random/_common.pxd | 40 +++++++++++++++++++--------------------
|
||||||
|
numpy/random/_common.pyx | 2 +-
|
||||||
|
numpy/random/_mt19937.pyx | 8 ++++----
|
||||||
|
numpy/random/_pcg64.pyx | 6 +++---
|
||||||
|
numpy/random/_philox.pyx | 6 +++---
|
||||||
|
numpy/random/_sfc64.pyx | 6 +++---
|
||||||
|
6 files changed, 34 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/numpy/random/_common.pxd b/numpy/random/_common.pxd
|
||||||
|
index 3eaf39d..5419d63 100644
|
||||||
|
--- a/numpy/random/_common.pxd
|
||||||
|
+++ b/numpy/random/_common.pxd
|
||||||
|
@@ -39,32 +39,32 @@ cdef extern from "include/aligned_malloc.h":
|
||||||
|
cdef void *PyArray_calloc_aligned(size_t n, size_t s)
|
||||||
|
cdef void PyArray_free_aligned(void *p)
|
||||||
|
|
||||||
|
-ctypedef void (*random_double_fill)(bitgen_t *state, np.npy_intp count, double* out) nogil
|
||||||
|
-ctypedef double (*random_double_0)(void *state) nogil
|
||||||
|
-ctypedef double (*random_double_1)(void *state, double a) nogil
|
||||||
|
-ctypedef double (*random_double_2)(void *state, double a, double b) nogil
|
||||||
|
-ctypedef double (*random_double_3)(void *state, double a, double b, double c) nogil
|
||||||
|
+ctypedef void (*random_double_fill)(bitgen_t *state, np.npy_intp count, double* out) noexcept nogil
|
||||||
|
+ctypedef double (*random_double_0)(void *state) noexcept nogil
|
||||||
|
+ctypedef double (*random_double_1)(void *state, double a) noexcept nogil
|
||||||
|
+ctypedef double (*random_double_2)(void *state, double a, double b) noexcept nogil
|
||||||
|
+ctypedef double (*random_double_3)(void *state, double a, double b, double c) noexcept nogil
|
||||||
|
|
||||||
|
-ctypedef void (*random_float_fill)(bitgen_t *state, np.npy_intp count, float* out) nogil
|
||||||
|
-ctypedef float (*random_float_0)(bitgen_t *state) nogil
|
||||||
|
-ctypedef float (*random_float_1)(bitgen_t *state, float a) nogil
|
||||||
|
+ctypedef void (*random_float_fill)(bitgen_t *state, np.npy_intp count, float* out) noexcept nogil
|
||||||
|
+ctypedef float (*random_float_0)(bitgen_t *state) noexcept nogil
|
||||||
|
+ctypedef float (*random_float_1)(bitgen_t *state, float a) noexcept nogil
|
||||||
|
|
||||||
|
-ctypedef int64_t (*random_uint_0)(void *state) nogil
|
||||||
|
-ctypedef int64_t (*random_uint_d)(void *state, double a) nogil
|
||||||
|
-ctypedef int64_t (*random_uint_dd)(void *state, double a, double b) nogil
|
||||||
|
-ctypedef int64_t (*random_uint_di)(void *state, double a, uint64_t b) nogil
|
||||||
|
-ctypedef int64_t (*random_uint_i)(void *state, int64_t a) nogil
|
||||||
|
-ctypedef int64_t (*random_uint_iii)(void *state, int64_t a, int64_t b, int64_t c) nogil
|
||||||
|
+ctypedef int64_t (*random_uint_0)(void *state) noexcept nogil
|
||||||
|
+ctypedef int64_t (*random_uint_d)(void *state, double a) noexcept nogil
|
||||||
|
+ctypedef int64_t (*random_uint_dd)(void *state, double a, double b) noexcept nogil
|
||||||
|
+ctypedef int64_t (*random_uint_di)(void *state, double a, uint64_t b) noexcept nogil
|
||||||
|
+ctypedef int64_t (*random_uint_i)(void *state, int64_t a) noexcept nogil
|
||||||
|
+ctypedef int64_t (*random_uint_iii)(void *state, int64_t a, int64_t b, int64_t c) noexcept nogil
|
||||||
|
|
||||||
|
-ctypedef uint32_t (*random_uint_0_32)(bitgen_t *state) nogil
|
||||||
|
-ctypedef uint32_t (*random_uint_1_i_32)(bitgen_t *state, uint32_t a) nogil
|
||||||
|
+ctypedef uint32_t (*random_uint_0_32)(bitgen_t *state) noexcept nogil
|
||||||
|
+ctypedef uint32_t (*random_uint_1_i_32)(bitgen_t *state, uint32_t a) noexcept nogil
|
||||||
|
|
||||||
|
-ctypedef int32_t (*random_int_2_i_32)(bitgen_t *state, int32_t a, int32_t b) nogil
|
||||||
|
-ctypedef int64_t (*random_int_2_i)(bitgen_t *state, int64_t a, int64_t b) nogil
|
||||||
|
+ctypedef int32_t (*random_int_2_i_32)(bitgen_t *state, int32_t a, int32_t b) noexcept nogil
|
||||||
|
+ctypedef int64_t (*random_int_2_i)(bitgen_t *state, int64_t a, int64_t b) noexcept nogil
|
||||||
|
|
||||||
|
-cdef double kahan_sum(double *darr, np.npy_intp n)
|
||||||
|
+cdef double kahan_sum(double *darr, np.npy_intp n) noexcept
|
||||||
|
|
||||||
|
-cdef inline double uint64_to_double(uint64_t rnd) nogil:
|
||||||
|
+cdef inline double uint64_to_double(uint64_t rnd) noexcept nogil:
|
||||||
|
return (rnd >> 11) * (1.0 / 9007199254740992.0)
|
||||||
|
|
||||||
|
cdef object double_fill(void *func, bitgen_t *state, object size, object lock, object out)
|
||||||
|
diff --git a/numpy/random/_common.pyx b/numpy/random/_common.pyx
|
||||||
|
index 7b6f693..c5e4e32 100644
|
||||||
|
--- a/numpy/random/_common.pyx
|
||||||
|
+++ b/numpy/random/_common.pyx
|
||||||
|
@@ -171,7 +171,7 @@ cdef object prepare_ctypes(bitgen_t *bitgen):
|
||||||
|
ctypes.c_void_p(<uintptr_t>bitgen))
|
||||||
|
return _ctypes
|
||||||
|
|
||||||
|
-cdef double kahan_sum(double *darr, np.npy_intp n):
|
||||||
|
+cdef double kahan_sum(double *darr, np.npy_intp n) noexcept:
|
||||||
|
"""
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
diff --git a/numpy/random/_mt19937.pyx b/numpy/random/_mt19937.pyx
|
||||||
|
index 5a8d52e..8b99125 100644
|
||||||
|
--- a/numpy/random/_mt19937.pyx
|
||||||
|
+++ b/numpy/random/_mt19937.pyx
|
||||||
|
@@ -28,16 +28,16 @@ cdef extern from "src/mt19937/mt19937.h":
|
||||||
|
enum:
|
||||||
|
RK_STATE_LEN
|
||||||
|
|
||||||
|
-cdef uint64_t mt19937_uint64(void *st) nogil:
|
||||||
|
+cdef uint64_t mt19937_uint64(void *st) noexcept nogil:
|
||||||
|
return mt19937_next64(<mt19937_state *> st)
|
||||||
|
|
||||||
|
-cdef uint32_t mt19937_uint32(void *st) nogil:
|
||||||
|
+cdef uint32_t mt19937_uint32(void *st) noexcept nogil:
|
||||||
|
return mt19937_next32(<mt19937_state *> st)
|
||||||
|
|
||||||
|
-cdef double mt19937_double(void *st) nogil:
|
||||||
|
+cdef double mt19937_double(void *st) noexcept nogil:
|
||||||
|
return mt19937_next_double(<mt19937_state *> st)
|
||||||
|
|
||||||
|
-cdef uint64_t mt19937_raw(void *st) nogil:
|
||||||
|
+cdef uint64_t mt19937_raw(void *st) noexcept nogil:
|
||||||
|
return <uint64_t>mt19937_next32(<mt19937_state *> st)
|
||||||
|
|
||||||
|
cdef class MT19937(BitGenerator):
|
||||||
|
diff --git a/numpy/random/_pcg64.pyx b/numpy/random/_pcg64.pyx
|
||||||
|
index c0a10a8..dee38c0 100644
|
||||||
|
--- a/numpy/random/_pcg64.pyx
|
||||||
|
+++ b/numpy/random/_pcg64.pyx
|
||||||
|
@@ -30,13 +30,13 @@ cdef extern from "src/pcg64/pcg64.h":
|
||||||
|
uint32_t pcg64_cm_next32(pcg64_state *state) nogil
|
||||||
|
void pcg64_cm_advance(pcg64_state *state, uint64_t *step)
|
||||||
|
|
||||||
|
-cdef uint64_t pcg64_uint64(void* st) nogil:
|
||||||
|
+cdef uint64_t pcg64_uint64(void* st) noexcept nogil:
|
||||||
|
return pcg64_next64(<pcg64_state *>st)
|
||||||
|
|
||||||
|
-cdef uint32_t pcg64_uint32(void *st) nogil:
|
||||||
|
+cdef uint32_t pcg64_uint32(void *st) noexcept nogil:
|
||||||
|
return pcg64_next32(<pcg64_state *> st)
|
||||||
|
|
||||||
|
-cdef double pcg64_double(void* st) nogil:
|
||||||
|
+cdef double pcg64_double(void* st) noexcept nogil:
|
||||||
|
return uint64_to_double(pcg64_next64(<pcg64_state *>st))
|
||||||
|
|
||||||
|
cdef uint64_t pcg64_cm_uint64(void* st) nogil:
|
||||||
|
diff --git a/numpy/random/_philox.pyx b/numpy/random/_philox.pyx
|
||||||
|
index d9a366e..e0c0504 100644
|
||||||
|
--- a/numpy/random/_philox.pyx
|
||||||
|
+++ b/numpy/random/_philox.pyx
|
||||||
|
@@ -42,13 +42,13 @@ cdef extern from 'src/philox/philox.h':
|
||||||
|
void philox_advance(uint64_t *step, philox_state *state)
|
||||||
|
|
||||||
|
|
||||||
|
-cdef uint64_t philox_uint64(void*st) nogil:
|
||||||
|
+cdef uint64_t philox_uint64(void*st) noexcept nogil:
|
||||||
|
return philox_next64(<philox_state *> st)
|
||||||
|
|
||||||
|
-cdef uint32_t philox_uint32(void *st) nogil:
|
||||||
|
+cdef uint32_t philox_uint32(void *st) noexcept nogil:
|
||||||
|
return philox_next32(<philox_state *> st)
|
||||||
|
|
||||||
|
-cdef double philox_double(void*st) nogil:
|
||||||
|
+cdef double philox_double(void*st) noexcept nogil:
|
||||||
|
return uint64_to_double(philox_next64(<philox_state *> st))
|
||||||
|
|
||||||
|
cdef class Philox(BitGenerator):
|
||||||
|
diff --git a/numpy/random/_sfc64.pyx b/numpy/random/_sfc64.pyx
|
||||||
|
index 1daee34..419045c 100644
|
||||||
|
--- a/numpy/random/_sfc64.pyx
|
||||||
|
+++ b/numpy/random/_sfc64.pyx
|
||||||
|
@@ -21,13 +21,13 @@ cdef extern from "src/sfc64/sfc64.h":
|
||||||
|
void sfc64_set_state(sfc64_state *state, uint64_t *state_arr, int has_uint32, uint32_t uinteger)
|
||||||
|
|
||||||
|
|
||||||
|
-cdef uint64_t sfc64_uint64(void* st) nogil:
|
||||||
|
+cdef uint64_t sfc64_uint64(void* st) noexcept nogil:
|
||||||
|
return sfc64_next64(<sfc64_state *>st)
|
||||||
|
|
||||||
|
-cdef uint32_t sfc64_uint32(void *st) nogil:
|
||||||
|
+cdef uint32_t sfc64_uint32(void *st) noexcept nogil:
|
||||||
|
return sfc64_next32(<sfc64_state *> st)
|
||||||
|
|
||||||
|
-cdef double sfc64_double(void* st) nogil:
|
||||||
|
+cdef double sfc64_double(void* st) noexcept nogil:
|
||||||
|
return uint64_to_double(sfc64_next64(<sfc64_state *>st))
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
|
|
||||||
|
From 910aff8c5827e13a7b8bb32e22604cf5e35943fc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Thomas A Caswell <tcaswell@gmail.com>
|
||||||
|
Date: Sat, 13 May 2023 21:33:45 -0400
|
||||||
|
Subject: [PATCH] MNT: compatibility with cython3
|
||||||
|
|
||||||
|
This is fallout from https://github.com/cython/cython/pull/5386
|
||||||
|
---
|
||||||
|
numpy/random/_pcg64.pyx | 11 +++++------
|
||||||
|
numpy/random/_philox.pyx | 4 ++--
|
||||||
|
2 files changed, 7 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/numpy/random/_pcg64.pyx b/numpy/random/_pcg64.pyx
|
||||||
|
index dee38c0..f7891aa 100644
|
||||||
|
--- a/numpy/random/_pcg64.pyx
|
||||||
|
+++ b/numpy/random/_pcg64.pyx
|
||||||
|
@@ -26,8 +26,8 @@ cdef extern from "src/pcg64/pcg64.h":
|
||||||
|
void pcg64_get_state(pcg64_state *state, uint64_t *state_arr, int *has_uint32, uint32_t *uinteger)
|
||||||
|
void pcg64_set_state(pcg64_state *state, uint64_t *state_arr, int has_uint32, uint32_t uinteger)
|
||||||
|
|
||||||
|
- uint64_t pcg64_cm_next64(pcg64_state *state) nogil
|
||||||
|
- uint32_t pcg64_cm_next32(pcg64_state *state) nogil
|
||||||
|
+ uint64_t pcg64_cm_next64(pcg64_state *state) noexcept nogil
|
||||||
|
+ uint32_t pcg64_cm_next32(pcg64_state *state) noexcept nogil
|
||||||
|
void pcg64_cm_advance(pcg64_state *state, uint64_t *step)
|
||||||
|
|
||||||
|
cdef uint64_t pcg64_uint64(void* st) noexcept nogil:
|
||||||
|
@@ -39,13 +39,13 @@ cdef uint32_t pcg64_uint32(void *st) noexcept nogil:
|
||||||
|
cdef double pcg64_double(void* st) noexcept nogil:
|
||||||
|
return uint64_to_double(pcg64_next64(<pcg64_state *>st))
|
||||||
|
|
||||||
|
-cdef uint64_t pcg64_cm_uint64(void* st) nogil:
|
||||||
|
+cdef uint64_t pcg64_cm_uint64(void* st) noexcept nogil:
|
||||||
|
return pcg64_cm_next64(<pcg64_state *>st)
|
||||||
|
|
||||||
|
-cdef uint32_t pcg64_cm_uint32(void *st) nogil:
|
||||||
|
+cdef uint32_t pcg64_cm_uint32(void *st) noexcept nogil:
|
||||||
|
return pcg64_cm_next32(<pcg64_state *> st)
|
||||||
|
|
||||||
|
-cdef double pcg64_cm_double(void* st) nogil:
|
||||||
|
+cdef double pcg64_cm_double(void* st) noexcept nogil:
|
||||||
|
return uint64_to_double(pcg64_cm_next64(<pcg64_state *>st))
|
||||||
|
|
||||||
|
cdef class PCG64(BitGenerator):
|
||||||
|
@@ -515,4 +515,3 @@ cdef class PCG64DXSM(BitGenerator):
|
||||||
|
pcg64_cm_advance(&self.rng_state, <uint64_t *>np.PyArray_DATA(d))
|
||||||
|
self._reset_state_variables()
|
||||||
|
return self
|
||||||
|
-
|
||||||
|
diff --git a/numpy/random/_philox.pyx b/numpy/random/_philox.pyx
|
||||||
|
index e0c0504..e535346 100644
|
||||||
|
--- a/numpy/random/_philox.pyx
|
||||||
|
+++ b/numpy/random/_philox.pyx
|
||||||
|
@@ -36,8 +36,8 @@ cdef extern from 'src/philox/philox.h':
|
||||||
|
|
||||||
|
ctypedef s_philox_state philox_state
|
||||||
|
|
||||||
|
- uint64_t philox_next64(philox_state *state) nogil
|
||||||
|
- uint32_t philox_next32(philox_state *state) nogil
|
||||||
|
+ uint64_t philox_next64(philox_state *state) noexcept nogil
|
||||||
|
+ uint32_t philox_next32(philox_state *state) noexcept nogil
|
||||||
|
void philox_jump(philox_state *state)
|
||||||
|
void philox_advance(uint64_t *step, philox_state *state)
|
||||||
|
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
|
|
||||||
|
From 83d7c201d7ad01fcacb8a3a8da3206f77a01f274 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||||
|
Date: Mon, 31 Jul 2023 11:46:23 +0200
|
||||||
|
Subject: [PATCH] Unpin Cython to allow 3
|
||||||
|
|
||||||
|
---
|
||||||
|
pyproject.toml | 2 +-
|
||||||
|
test_requirements.txt | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pyproject.toml b/pyproject.toml
|
||||||
|
index 60e7f58..557ae21 100644
|
||||||
|
--- a/pyproject.toml
|
||||||
|
+++ b/pyproject.toml
|
||||||
|
@@ -3,7 +3,7 @@
|
||||||
|
requires = [
|
||||||
|
"setuptools==59.2.0",
|
||||||
|
"wheel==0.37.0",
|
||||||
|
- "Cython>=0.29.30,<3.0",
|
||||||
|
+ "Cython>=0.29.34",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/test_requirements.txt b/test_requirements.txt
|
||||||
|
index 67b6a48..a065e99 100644
|
||||||
|
--- a/test_requirements.txt
|
||||||
|
+++ b/test_requirements.txt
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
-cython>=0.29.30,<3.0
|
||||||
|
+cython>=0.29.34
|
||||||
|
wheel==0.37.0
|
||||||
|
setuptools==59.2.0
|
||||||
|
hypothesis==6.24.1
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
@ -1,144 +0,0 @@
|
|||||||
From eeef9d4646103c3b1afd3085f1393f2b3f9575b2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: NectDz <54990613+NectDz@users.noreply.github.com>
|
|
||||||
Date: Tue, 10 Aug 2021 18:00:35 -0500
|
|
||||||
Subject: [PATCH] DEP: Remove deprecated numeric style dtype strings (#19539)
|
|
||||||
|
|
||||||
Finishes the deprecation, and effectively closes gh-18993
|
|
||||||
|
|
||||||
* Insecure String Comparison
|
|
||||||
|
|
||||||
* Finished Deprecations
|
|
||||||
|
|
||||||
* Breaks numpy types
|
|
||||||
|
|
||||||
* Removed elements in dep_tps
|
|
||||||
|
|
||||||
* Delete Typecode Comment
|
|
||||||
|
|
||||||
* Deleted for loop
|
|
||||||
|
|
||||||
* Fixed 80 characters or more issue
|
|
||||||
|
|
||||||
* Expired Release Note
|
|
||||||
|
|
||||||
* Updated Release Note
|
|
||||||
|
|
||||||
* Update numpy/core/numerictypes.py
|
|
||||||
|
|
||||||
* Update numpy/core/tests/test_deprecations.py
|
|
||||||
|
|
||||||
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
|
||||||
---
|
|
||||||
doc/release/upcoming_changes/19539.expired.rst | 2 ++
|
|
||||||
numpy/core/_type_aliases.py | 9 ---------
|
|
||||||
numpy/core/src/multiarray/descriptor.c | 16 ----------------
|
|
||||||
numpy/core/tests/test_deprecations.py | 15 ---------------
|
|
||||||
numpy/core/tests/test_dtype.py | 9 ++++++---
|
|
||||||
5 files changed, 8 insertions(+), 43 deletions(-)
|
|
||||||
create mode 100644 doc/release/upcoming_changes/19539.expired.rst
|
|
||||||
|
|
||||||
diff --git a/doc/release/upcoming_changes/19539.expired.rst b/doc/release/upcoming_changes/19539.expired.rst
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..6e94f17
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/doc/release/upcoming_changes/19539.expired.rst
|
|
||||||
@@ -0,0 +1,2 @@
|
|
||||||
+* Using the strings ``"Bytes0"``, ``"Datetime64"``, ``"Str0"``, ``"Uint32"``,
|
|
||||||
+ and ``"Uint64"`` as a dtype will now raise a ``TypeError``.
|
|
||||||
\ No newline at end of file
|
|
||||||
diff --git a/numpy/core/_type_aliases.py b/numpy/core/_type_aliases.py
|
|
||||||
index 67addef..3765a0d 100644
|
|
||||||
--- a/numpy/core/_type_aliases.py
|
|
||||||
+++ b/numpy/core/_type_aliases.py
|
|
||||||
@@ -115,15 +115,6 @@ def _add_aliases():
|
|
||||||
# add forward, reverse, and string mapping to numarray
|
|
||||||
sctypeDict[char] = info.type
|
|
||||||
|
|
||||||
- # Add deprecated numeric-style type aliases manually, at some point
|
|
||||||
- # we may want to deprecate the lower case "bytes0" version as well.
|
|
||||||
- for name in ["Bytes0", "Datetime64", "Str0", "Uint32", "Uint64"]:
|
|
||||||
- if english_lower(name) not in allTypes:
|
|
||||||
- # Only one of Uint32 or Uint64, aliases of `np.uintp`, was (and is) defined, note that this
|
|
||||||
- # is not UInt32/UInt64 (capital i), which is removed.
|
|
||||||
- continue
|
|
||||||
- allTypes[name] = allTypes[english_lower(name)]
|
|
||||||
- sctypeDict[name] = sctypeDict[english_lower(name)]
|
|
||||||
|
|
||||||
_add_aliases()
|
|
||||||
|
|
||||||
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
|
|
||||||
index 50964da..90453e3 100644
|
|
||||||
--- a/numpy/core/src/multiarray/descriptor.c
|
|
||||||
+++ b/numpy/core/src/multiarray/descriptor.c
|
|
||||||
@@ -1723,22 +1723,6 @@ _convert_from_str(PyObject *obj, int align)
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
- /* Check for a deprecated Numeric-style typecode */
|
|
||||||
- /* `Uint` has deliberately weird uppercasing */
|
|
||||||
- char *dep_tps[] = {"Bytes", "Datetime64", "Str", "Uint"};
|
|
||||||
- int ndep_tps = sizeof(dep_tps) / sizeof(dep_tps[0]);
|
|
||||||
- for (int i = 0; i < ndep_tps; ++i) {
|
|
||||||
- char *dep_tp = dep_tps[i];
|
|
||||||
-
|
|
||||||
- if (strncmp(type, dep_tp, strlen(dep_tp)) == 0) {
|
|
||||||
- /* Deprecated 2020-06-09, NumPy 1.20 */
|
|
||||||
- if (DEPRECATE("Numeric-style type codes are "
|
|
||||||
- "deprecated and will result in "
|
|
||||||
- "an error in the future.") < 0) {
|
|
||||||
- goto fail;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
/*
|
|
||||||
* Probably only ever dispatches to `_convert_from_type`, but who
|
|
||||||
* knows what users are injecting into `np.typeDict`.
|
|
||||||
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
|
|
||||||
index 42e632e..44a3ed7 100644
|
|
||||||
--- a/numpy/core/tests/test_deprecations.py
|
|
||||||
+++ b/numpy/core/tests/test_deprecations.py
|
|
||||||
@@ -314,21 +314,6 @@ def test_insufficient_width_negative(self):
|
|
||||||
self.assert_deprecated(np.binary_repr, args=args, kwargs=kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
-class TestNumericStyleTypecodes(_DeprecationTestCase):
|
|
||||||
- """
|
|
||||||
- Most numeric style typecodes were previously deprecated (and removed)
|
|
||||||
- in 1.20. This also deprecates the remaining ones.
|
|
||||||
- """
|
|
||||||
- # 2020-06-09, NumPy 1.20
|
|
||||||
- def test_all_dtypes(self):
|
|
||||||
- deprecated_types = ['Bytes0', 'Datetime64', 'Str0']
|
|
||||||
- # Depending on intp size, either Uint32 or Uint64 is defined:
|
|
||||||
- deprecated_types.append(f"U{np.dtype(np.intp).name}")
|
|
||||||
- for dt in deprecated_types:
|
|
||||||
- self.assert_deprecated(np.dtype, exceptions=(TypeError,),
|
|
||||||
- args=(dt,))
|
|
||||||
-
|
|
||||||
-
|
|
||||||
class TestDTypeAttributeIsDTypeDeprecation(_DeprecationTestCase):
|
|
||||||
# Deprecated 2021-01-05, NumPy 1.21
|
|
||||||
message = r".*`.dtype` attribute"
|
|
||||||
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
|
|
||||||
index 4f52268..23269f0 100644
|
|
||||||
--- a/numpy/core/tests/test_dtype.py
|
|
||||||
+++ b/numpy/core/tests/test_dtype.py
|
|
||||||
@@ -109,9 +109,12 @@ def test_richcompare_invalid_dtype_comparison(self, operation):
|
|
||||||
operation(np.dtype(np.int32), 7)
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("dtype",
|
|
||||||
- ['Bool', 'Complex32', 'Complex64', 'Float16', 'Float32', 'Float64',
|
|
||||||
- 'Int8', 'Int16', 'Int32', 'Int64', 'Object0', 'Timedelta64',
|
|
||||||
- 'UInt8', 'UInt16', 'UInt32', 'UInt64', 'Void0',
|
|
||||||
+ ['Bool', 'Bytes0', 'Complex32', 'Complex64',
|
|
||||||
+ 'Datetime64', 'Float16', 'Float32', 'Float64',
|
|
||||||
+ 'Int8', 'Int16', 'Int32', 'Int64',
|
|
||||||
+ 'Object0', 'Str0', 'Timedelta64',
|
|
||||||
+ 'UInt8', 'UInt16', 'Uint32', 'UInt32',
|
|
||||||
+ 'Uint64', 'UInt64', 'Void0',
|
|
||||||
"Float128", "Complex128"])
|
|
||||||
def test_numeric_style_types_are_invalid(self, dtype):
|
|
||||||
with assert_raises(TypeError):
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,461 +0,0 @@
|
|||||||
From ac87f071f5fcf05b6a28bcf4ba7eb965daa6959a Mon Sep 17 00:00:00 2001
|
|
||||||
From: Matti Picus <matti.picus@gmail.com>
|
|
||||||
Date: Wed, 2 Feb 2022 22:46:17 +0200
|
|
||||||
Subject: [PATCH] ENH: review return values for PyArray_DescrNew (#20960)
|
|
||||||
|
|
||||||
* ENH: review return value from PyArray_DescrNew* calls
|
|
||||||
|
|
||||||
* BUG: remove unused variable
|
|
||||||
|
|
||||||
* BUG: typo
|
|
||||||
|
|
||||||
* Update numpy/core/src/multiarray/methods.c
|
|
||||||
|
|
||||||
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
|
||||||
|
|
||||||
* Update numpy/core/src/multiarray/methods.c
|
|
||||||
|
|
||||||
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
|
||||||
|
|
||||||
* Update numpy/core/src/multiarray/getset.c
|
|
||||||
|
|
||||||
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
|
||||||
|
|
||||||
* Update numpy/core/src/multiarray/methods.c
|
|
||||||
|
|
||||||
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
|
||||||
|
|
||||||
* fixes from review
|
|
||||||
|
|
||||||
* Update numpy/core/src/umath/ufunc_type_resolution.c
|
|
||||||
|
|
||||||
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
|
||||||
|
|
||||||
* move check to internal function
|
|
||||||
|
|
||||||
* remove check
|
|
||||||
|
|
||||||
* Remove unnecessary dealloc
|
|
||||||
|
|
||||||
The dealloc is now part of the Py_DECREF(ret) and handled there.
|
|
||||||
Doing it here would decref it twice.
|
|
||||||
|
|
||||||
* MAINT: Remove custom error message (and small cleanup)
|
|
||||||
|
|
||||||
It is probably not good to call PyObject_GetIter() if dtype is NULL
|
|
||||||
and an error is already in progress...
|
|
||||||
(If we check for it, lets try to do it right.)
|
|
||||||
|
|
||||||
* Fixup DescrNewFromType
|
|
||||||
|
|
||||||
`DescrNewFromType` cannot fail in most cases, but if it does,
|
|
||||||
DescrNew does not accept NULL as input.
|
|
||||||
|
|
||||||
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
|
||||||
---
|
|
||||||
numpy/core/src/multiarray/_multiarray_tests.c.src | 4 +--
|
|
||||||
numpy/core/src/multiarray/arrayobject.c | 3 +++
|
|
||||||
numpy/core/src/multiarray/buffer.c | 6 +++++
|
|
||||||
numpy/core/src/multiarray/ctors.c | 24 +++++++++++++++++-
|
|
||||||
numpy/core/src/multiarray/descriptor.c | 30 +++++++++++++++++------
|
|
||||||
numpy/core/src/multiarray/dtypemeta.c | 8 ++++++
|
|
||||||
numpy/core/src/multiarray/getset.c | 13 ++++++----
|
|
||||||
numpy/core/src/multiarray/methods.c | 16 ++++++++++++
|
|
||||||
numpy/core/src/multiarray/nditer_constr.c | 11 ++++-----
|
|
||||||
numpy/core/src/multiarray/scalarapi.c | 3 +++
|
|
||||||
numpy/core/src/multiarray/scalartypes.c.src | 10 +++++---
|
|
||||||
11 files changed, 103 insertions(+), 25 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/numpy/core/src/multiarray/_multiarray_tests.c.src b/numpy/core/src/multiarray/_multiarray_tests.c.src
|
|
||||||
index 3693762..fd7c1d0 100644
|
|
||||||
--- a/numpy/core/src/multiarray/_multiarray_tests.c.src
|
|
||||||
+++ b/numpy/core/src/multiarray/_multiarray_tests.c.src
|
|
||||||
@@ -643,14 +643,12 @@ static PyObject *
|
|
||||||
fromstring_null_term_c_api(PyObject *dummy, PyObject *byte_obj)
|
|
||||||
{
|
|
||||||
char *string;
|
|
||||||
- PyArray_Descr *descr;
|
|
||||||
|
|
||||||
string = PyBytes_AsString(byte_obj);
|
|
||||||
if (string == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
- descr = PyArray_DescrNewFromType(NPY_FLOAT64);
|
|
||||||
- return PyArray_FromString(string, -1, descr, -1, " ");
|
|
||||||
+ return PyArray_FromString(string, -1, NULL, -1, " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c
|
|
||||||
index 3f080d9..4c20fc1 100644
|
|
||||||
--- a/numpy/core/src/multiarray/arrayobject.c
|
|
||||||
+++ b/numpy/core/src/multiarray/arrayobject.c
|
|
||||||
@@ -986,6 +986,9 @@ _strings_richcompare(PyArrayObject *self, PyArrayObject *other, int cmp_op,
|
|
||||||
if (PyArray_TYPE(self) == NPY_STRING &&
|
|
||||||
PyArray_DESCR(other)->type_num == NPY_UNICODE) {
|
|
||||||
PyArray_Descr* unicode = PyArray_DescrNew(PyArray_DESCR(other));
|
|
||||||
+ if (unicode == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
unicode->elsize = PyArray_DESCR(self)->elsize << 2;
|
|
||||||
new = PyArray_FromAny((PyObject *)self, unicode,
|
|
||||||
0, 0, 0, NULL);
|
|
||||||
diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c
|
|
||||||
index d10122c..d14f87a 100644
|
|
||||||
--- a/numpy/core/src/multiarray/buffer.c
|
|
||||||
+++ b/numpy/core/src/multiarray/buffer.c
|
|
||||||
@@ -1048,12 +1048,18 @@ _descriptor_from_pep3118_format_fast(char const *s, PyObject **result)
|
|
||||||
}
|
|
||||||
|
|
||||||
descr = PyArray_DescrFromType(type_num);
|
|
||||||
+ if (descr == NULL) {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
if (byte_order == '=') {
|
|
||||||
*result = (PyObject*)descr;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
*result = (PyObject*)PyArray_DescrNewByteorder(descr, byte_order);
|
|
||||||
Py_DECREF(descr);
|
|
||||||
+ if (result == NULL) {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
|
|
||||||
index 7b7f977..6991bba 100644
|
|
||||||
--- a/numpy/core/src/multiarray/ctors.c
|
|
||||||
+++ b/numpy/core/src/multiarray/ctors.c
|
|
||||||
@@ -668,6 +668,9 @@ PyArray_NewFromDescr_int(
|
|
||||||
PyArrayObject_fields *fa;
|
|
||||||
npy_intp nbytes;
|
|
||||||
|
|
||||||
+ if (descr == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
if (nd > NPY_MAXDIMS || nd < 0) {
|
|
||||||
PyErr_Format(PyExc_ValueError,
|
|
||||||
"number of dimensions must be within [0, %d]", NPY_MAXDIMS);
|
|
||||||
@@ -1137,6 +1140,9 @@ PyArray_New(
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
PyArray_DESCR_REPLACE(descr);
|
|
||||||
+ if (descr == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
descr->elsize = itemsize;
|
|
||||||
}
|
|
||||||
new = PyArray_NewFromDescr(subtype, descr, nd, dims, strides,
|
|
||||||
@@ -1162,6 +1168,9 @@ _dtype_from_buffer_3118(PyObject *memoryview)
|
|
||||||
* terminate.
|
|
||||||
*/
|
|
||||||
descr = PyArray_DescrNewFromType(NPY_STRING);
|
|
||||||
+ if (descr == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
descr->elsize = view->itemsize;
|
|
||||||
}
|
|
||||||
return descr;
|
|
||||||
@@ -3559,6 +3568,10 @@ PyArray_FromFile(FILE *fp, PyArray_Descr *dtype, npy_intp num, char *sep)
|
|
||||||
PyArrayObject *ret;
|
|
||||||
size_t nread = 0;
|
|
||||||
|
|
||||||
+ if (dtype == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (PyDataType_REFCHK(dtype)) {
|
|
||||||
PyErr_SetString(PyExc_ValueError,
|
|
||||||
"Cannot read into object array");
|
|
||||||
@@ -3626,6 +3639,9 @@ PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type,
|
|
||||||
int itemsize;
|
|
||||||
int writeable = 1;
|
|
||||||
|
|
||||||
+ if (type == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
if (PyDataType_REFCHK(type)) {
|
|
||||||
PyErr_SetString(PyExc_ValueError,
|
|
||||||
@@ -3833,14 +3849,20 @@ NPY_NO_EXPORT PyObject *
|
|
||||||
PyArray_FromIter(PyObject *obj, PyArray_Descr *dtype, npy_intp count)
|
|
||||||
{
|
|
||||||
PyObject *value;
|
|
||||||
- PyObject *iter = PyObject_GetIter(obj);
|
|
||||||
+ PyObject *iter = NULL;
|
|
||||||
PyArrayObject *ret = NULL;
|
|
||||||
npy_intp i, elsize, elcount;
|
|
||||||
char *item, *new_data;
|
|
||||||
|
|
||||||
+ if (dtype == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ iter = PyObject_GetIter(obj);
|
|
||||||
if (iter == NULL) {
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
if (PyDataType_ISUNSIZED(dtype)) {
|
|
||||||
PyErr_SetString(PyExc_ValueError,
|
|
||||||
"Must specify length when using variable-size data-type.");
|
|
||||||
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
|
|
||||||
index 0c53905..a5cb6a9 100644
|
|
||||||
--- a/numpy/core/src/multiarray/descriptor.c
|
|
||||||
+++ b/numpy/core/src/multiarray/descriptor.c
|
|
||||||
@@ -1381,6 +1381,9 @@ PyArray_DescrNewFromType(int type_num)
|
|
||||||
PyArray_Descr *new;
|
|
||||||
|
|
||||||
old = PyArray_DescrFromType(type_num);
|
|
||||||
+ if (old == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
new = PyArray_DescrNew(old);
|
|
||||||
Py_DECREF(old);
|
|
||||||
return new;
|
|
||||||
@@ -2341,7 +2344,7 @@ arraydescr_new(PyTypeObject *subtype,
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *odescr, *metadata=NULL;
|
|
||||||
- PyArray_Descr *descr, *conv;
|
|
||||||
+ PyArray_Descr *conv;
|
|
||||||
npy_bool align = NPY_FALSE;
|
|
||||||
npy_bool copy = NPY_FALSE;
|
|
||||||
npy_bool copied = NPY_FALSE;
|
|
||||||
@@ -2363,9 +2366,10 @@ arraydescr_new(PyTypeObject *subtype,
|
|
||||||
|
|
||||||
/* Get a new copy of it unless it's already a copy */
|
|
||||||
if (copy && conv->fields == Py_None) {
|
|
||||||
- descr = PyArray_DescrNew(conv);
|
|
||||||
- Py_DECREF(conv);
|
|
||||||
- conv = descr;
|
|
||||||
+ PyArray_DESCR_REPLACE(conv);
|
|
||||||
+ if (conv == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
copied = NPY_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2375,10 +2379,11 @@ arraydescr_new(PyTypeObject *subtype,
|
|
||||||
* underlying dictionary
|
|
||||||
*/
|
|
||||||
if (!copied) {
|
|
||||||
+ PyArray_DESCR_REPLACE(conv);
|
|
||||||
+ if (conv == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
copied = NPY_TRUE;
|
|
||||||
- descr = PyArray_DescrNew(conv);
|
|
||||||
- Py_DECREF(conv);
|
|
||||||
- conv = descr;
|
|
||||||
}
|
|
||||||
if ((conv->metadata != NULL)) {
|
|
||||||
/*
|
|
||||||
@@ -3047,6 +3052,9 @@ PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)
|
|
||||||
char endian;
|
|
||||||
|
|
||||||
new = PyArray_DescrNew(self);
|
|
||||||
+ if (new == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
endian = new->byteorder;
|
|
||||||
if (endian != NPY_IGNORE) {
|
|
||||||
if (newendian == NPY_SWAP) {
|
|
||||||
@@ -3073,6 +3081,10 @@ PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)
|
|
||||||
int len, i;
|
|
||||||
|
|
||||||
newfields = PyDict_New();
|
|
||||||
+ if (newfields == NULL) {
|
|
||||||
+ Py_DECREF(new);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
/* make new dictionary with replaced PyArray_Descr Objects */
|
|
||||||
while (PyDict_Next(self->fields, &pos, &key, &value)) {
|
|
||||||
if (NPY_TITLE_KEY(key, value)) {
|
|
||||||
@@ -3114,6 +3126,10 @@ PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)
|
|
||||||
Py_DECREF(new->subarray->base);
|
|
||||||
new->subarray->base = PyArray_DescrNewByteorder(
|
|
||||||
self->subarray->base, newendian);
|
|
||||||
+ if (new->subarray->base == NULL) {
|
|
||||||
+ Py_DECREF(new);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
return new;
|
|
||||||
}
|
|
||||||
diff --git a/numpy/core/src/multiarray/dtypemeta.c b/numpy/core/src/multiarray/dtypemeta.c
|
|
||||||
index cd489d5..53f38e8 100644
|
|
||||||
--- a/numpy/core/src/multiarray/dtypemeta.c
|
|
||||||
+++ b/numpy/core/src/multiarray/dtypemeta.c
|
|
||||||
@@ -153,6 +153,9 @@ string_discover_descr_from_pyobject(
|
|
||||||
"string to large to store inside array.");
|
|
||||||
}
|
|
||||||
PyArray_Descr *res = PyArray_DescrNewFromType(cls->type_num);
|
|
||||||
+ if (res == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
res->elsize = (int)itemsize;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
@@ -171,10 +174,15 @@ void_discover_descr_from_pyobject(
|
|
||||||
}
|
|
||||||
if (PyBytes_Check(obj)) {
|
|
||||||
PyArray_Descr *descr = PyArray_DescrNewFromType(NPY_VOID);
|
|
||||||
+ if (descr == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
Py_ssize_t itemsize = PyBytes_Size(obj);
|
|
||||||
if (itemsize > NPY_MAX_INT) {
|
|
||||||
PyErr_SetString(PyExc_TypeError,
|
|
||||||
"byte-like to large to store inside array.");
|
|
||||||
+ Py_DECREF(descr);
|
|
||||||
+ return NULL;
|
|
||||||
}
|
|
||||||
descr->elsize = (int)itemsize;
|
|
||||||
return descr;
|
|
||||||
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
|
|
||||||
index a4f972b..d640684 100644
|
|
||||||
--- a/numpy/core/src/multiarray/getset.c
|
|
||||||
+++ b/numpy/core/src/multiarray/getset.c
|
|
||||||
@@ -698,15 +698,18 @@ _get_part(PyArrayObject *self, int imag)
|
|
||||||
|
|
||||||
}
|
|
||||||
type = PyArray_DescrFromType(float_type_num);
|
|
||||||
+ if (type == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
|
|
||||||
offset = (imag ? type->elsize : 0);
|
|
||||||
|
|
||||||
if (!PyArray_ISNBO(PyArray_DESCR(self)->byteorder)) {
|
|
||||||
- PyArray_Descr *new;
|
|
||||||
- new = PyArray_DescrNew(type);
|
|
||||||
- new->byteorder = PyArray_DESCR(self)->byteorder;
|
|
||||||
- Py_DECREF(type);
|
|
||||||
- type = new;
|
|
||||||
+ Py_SETREF(type, PyArray_DescrNew(type));
|
|
||||||
+ if (type == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+ type->byteorder = PyArray_DESCR(self)->byteorder;
|
|
||||||
}
|
|
||||||
ret = (PyArrayObject *)PyArray_NewFromDescrAndBase(
|
|
||||||
Py_TYPE(self),
|
|
||||||
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c
|
|
||||||
index 33f78df..2edbc23 100644
|
|
||||||
--- a/numpy/core/src/multiarray/methods.c
|
|
||||||
+++ b/numpy/core/src/multiarray/methods.c
|
|
||||||
@@ -1337,6 +1337,10 @@ array_sort(PyArrayObject *self,
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
newd = PyArray_DescrNew(saved);
|
|
||||||
+ if (newd == NULL) {
|
|
||||||
+ Py_DECREF(new_name);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
Py_DECREF(newd->names);
|
|
||||||
newd->names = new_name;
|
|
||||||
((PyArrayObject_fields *)self)->descr = newd;
|
|
||||||
@@ -1462,6 +1466,10 @@ array_argsort(PyArrayObject *self,
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
newd = PyArray_DescrNew(saved);
|
|
||||||
+ if (newd == NULL) {
|
|
||||||
+ Py_DECREF(new_name);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
Py_DECREF(newd->names);
|
|
||||||
newd->names = new_name;
|
|
||||||
((PyArrayObject_fields *)self)->descr = newd;
|
|
||||||
@@ -1519,6 +1527,10 @@ array_argpartition(PyArrayObject *self,
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
newd = PyArray_DescrNew(saved);
|
|
||||||
+ if (newd == NULL) {
|
|
||||||
+ Py_DECREF(new_name);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
Py_DECREF(newd->names);
|
|
||||||
newd->names = new_name;
|
|
||||||
((PyArrayObject_fields *)self)->descr = newd;
|
|
||||||
@@ -2150,6 +2161,10 @@ array_setstate(PyArrayObject *self, PyObject *args)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fa->descr = PyArray_DescrNew(typecode);
|
|
||||||
+ if (fa->descr == NULL) {
|
|
||||||
+ Py_DECREF(rawdata);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
if (PyArray_DESCR(self)->byteorder == NPY_BIG) {
|
|
||||||
PyArray_DESCR(self)->byteorder = NPY_LITTLE;
|
|
||||||
}
|
|
||||||
diff --git a/numpy/core/src/multiarray/nditer_constr.c b/numpy/core/src/multiarray/nditer_constr.c
|
|
||||||
index 0b9717a..f82a962 100644
|
|
||||||
--- a/numpy/core/src/multiarray/nditer_constr.c
|
|
||||||
+++ b/numpy/core/src/multiarray/nditer_constr.c
|
|
||||||
@@ -1128,13 +1128,12 @@ npyiter_prepare_one_operand(PyArrayObject **op,
|
|
||||||
if (op_flags & NPY_ITER_NBO) {
|
|
||||||
/* Check byte order */
|
|
||||||
if (!PyArray_ISNBO((*op_dtype)->byteorder)) {
|
|
||||||
- PyArray_Descr *nbo_dtype;
|
|
||||||
-
|
|
||||||
/* Replace with a new descr which is in native byte order */
|
|
||||||
- nbo_dtype = PyArray_DescrNewByteorder(*op_dtype, NPY_NATIVE);
|
|
||||||
- Py_DECREF(*op_dtype);
|
|
||||||
- *op_dtype = nbo_dtype;
|
|
||||||
-
|
|
||||||
+ Py_SETREF(*op_dtype,
|
|
||||||
+ PyArray_DescrNewByteorder(*op_dtype, NPY_NATIVE));
|
|
||||||
+ if (*op_dtype == NULL) {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
NPY_IT_DBG_PRINT("Iterator: Setting NPY_OP_ITFLAG_CAST "
|
|
||||||
"because of NPY_ITER_NBO\n");
|
|
||||||
/* Indicate that byte order or alignment needs fixing */
|
|
||||||
diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c
|
|
||||||
index 564352f..edbe595 100644
|
|
||||||
--- a/numpy/core/src/multiarray/scalarapi.c
|
|
||||||
+++ b/numpy/core/src/multiarray/scalarapi.c
|
|
||||||
@@ -625,6 +625,9 @@ PyArray_DescrFromScalar(PyObject *sc)
|
|
||||||
}
|
|
||||||
if (PyDataType_ISUNSIZED(descr)) {
|
|
||||||
PyArray_DESCR_REPLACE(descr);
|
|
||||||
+ if (descr == NULL) {
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
type_num = descr->type_num;
|
|
||||||
if (type_num == NPY_STRING) {
|
|
||||||
descr->elsize = PyBytes_GET_SIZE(sc);
|
|
||||||
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src
|
|
||||||
index 9077618..af98145 100644
|
|
||||||
--- a/numpy/core/src/multiarray/scalartypes.c.src
|
|
||||||
+++ b/numpy/core/src/multiarray/scalartypes.c.src
|
|
||||||
@@ -3212,12 +3212,16 @@ void_arrtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|
||||||
}
|
|
||||||
((PyVoidScalarObject *)ret)->obval = destptr;
|
|
||||||
Py_SET_SIZE((PyVoidScalarObject *)ret, (int) memu);
|
|
||||||
- ((PyVoidScalarObject *)ret)->descr =
|
|
||||||
- PyArray_DescrNewFromType(NPY_VOID);
|
|
||||||
- ((PyVoidScalarObject *)ret)->descr->elsize = (int) memu;
|
|
||||||
((PyVoidScalarObject *)ret)->flags = NPY_ARRAY_BEHAVED |
|
|
||||||
NPY_ARRAY_OWNDATA;
|
|
||||||
((PyVoidScalarObject *)ret)->base = NULL;
|
|
||||||
+ ((PyVoidScalarObject *)ret)->descr =
|
|
||||||
+ PyArray_DescrNewFromType(NPY_VOID);
|
|
||||||
+ if (((PyVoidScalarObject *)ret)->descr == NULL) {
|
|
||||||
+ Py_DECREF(ret);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+ ((PyVoidScalarObject *)ret)->descr->elsize = (int) memu;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
--- a/numpy/core/src/multiarray/arrayobject.c
|
|
||||||
+++ b/numpy/core/src/multiarray/arrayobject.c
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
From 271010f1037150e95017f803f4214b8861e528f2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Warren Weckesser <warren.weckesser@gmail.com>
|
|
||||||
Date: Mon, 20 Dec 2021 10:35:31 -0500
|
|
||||||
Subject: [PATCH] BUG: f2py: Simplify creation of an exception message. Closes
|
|
||||||
gh-19000.
|
|
||||||
|
|
||||||
---
|
|
||||||
numpy/f2py/src/fortranobject.c | 28 +++++++++++++---------------
|
|
||||||
1 file changed, 13 insertions(+), 15 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c
|
|
||||||
index 4a981bf..d323878 100644
|
|
||||||
--- a/numpy/f2py/src/fortranobject.c
|
|
||||||
+++ b/numpy/f2py/src/fortranobject.c
|
|
||||||
@@ -595,14 +595,14 @@ static int check_and_fix_dimensions(const PyArrayObject* arr,
|
|
||||||
npy_intp *dims);
|
|
||||||
|
|
||||||
static int
|
|
||||||
-count_negative_dimensions(const int rank,
|
|
||||||
- const npy_intp *dims) {
|
|
||||||
- int i=0,r=0;
|
|
||||||
- while (i<rank) {
|
|
||||||
- if (dims[i] < 0) ++r;
|
|
||||||
- ++i;
|
|
||||||
+find_first_negative_dimension(const int rank, const npy_intp *dims)
|
|
||||||
+{
|
|
||||||
+ for (int i = 0; i < rank; ++i) {
|
|
||||||
+ if (dims[i] < 0) {
|
|
||||||
+ return i;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
- return r;
|
|
||||||
+ return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_COPY_ND_ARRAY
|
|
||||||
@@ -679,14 +679,12 @@ PyArrayObject* array_from_pyobj(const int type_num,
|
|
||||||
|| ((intent & F2PY_OPTIONAL) && (obj==Py_None))
|
|
||||||
) {
|
|
||||||
/* intent(cache), optional, intent(hide) */
|
|
||||||
- if (count_negative_dimensions(rank,dims) > 0) {
|
|
||||||
- int i;
|
|
||||||
- strcpy(mess, "failed to create intent(cache|hide)|optional array"
|
|
||||||
- "-- must have defined dimensions but got (");
|
|
||||||
- for(i=0;i<rank;++i)
|
|
||||||
- sprintf(mess+strlen(mess),"%" NPY_INTP_FMT ",",dims[i]);
|
|
||||||
- strcat(mess, ")");
|
|
||||||
- PyErr_SetString(PyExc_ValueError,mess);
|
|
||||||
+ int i = find_first_negative_dimension(rank, dims);
|
|
||||||
+ if (i >= 0) {
|
|
||||||
+ PyErr_Format(PyExc_ValueError,
|
|
||||||
+ "failed to create intent(cache|hide)|optional array"
|
|
||||||
+ " -- must have defined dimensions, but dims[%d] = %"
|
|
||||||
+ NPY_INTP_FMT, i, dims[i]);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
arr = (PyArrayObject *)
|
|
||||||
--
|
|
||||||
2.27.0
|
|
||||||
|
|
||||||
Binary file not shown.
45
numpy.spec
45
numpy.spec
@ -1,22 +1,20 @@
|
|||||||
%global modname numpy
|
%global modname numpy
|
||||||
|
|
||||||
Name: numpy
|
Name: numpy
|
||||||
Version: 1.21.4
|
Version: 1.24.3
|
||||||
Release: 4
|
Release: 3
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Summary: A fast multidimensional array facility for Python
|
Summary: A fast multidimensional array facility for Python
|
||||||
|
|
||||||
License: ASL 2.0
|
License: ASL 2.0
|
||||||
URL: http://www.numpy.org/
|
URL: http://www.numpy.org/
|
||||||
Source0: https://files.pythonhosted.org/packages/fb/48/b0708ebd7718a8933f0d3937513ef8ef2f4f04529f1f66ca86d873043921/numpy-1.21.4.zip
|
Source0: https://files.pythonhosted.org/packages/source/n/numpy/numpy-%{version}.tar.gz
|
||||||
|
|
||||||
|
Patch0: adapted-cython3_noexcept.patch
|
||||||
|
|
||||||
BuildRequires: openblas-devel
|
BuildRequires: openblas-devel
|
||||||
BuildRequires: lapack-devel gcc-gfortran
|
BuildRequires: lapack-devel gcc-gfortran
|
||||||
BuildRequires: python3-Cython >= 0.29.24
|
BuildRequires: python3-Cython >= 0.29.24 chrpath gcc-c++
|
||||||
|
|
||||||
Patch0: backport-CVE-2021-41496.patch
|
|
||||||
Patch1: backport-CVE-2021-41495.patch
|
|
||||||
Patch2: backport-CVE-2021-34141.patch
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
NumPy is the fundamental package for scientific computing with Python. It contains among other things:
|
NumPy is the fundamental package for scientific computing with Python. It contains among other things:
|
||||||
@ -84,6 +82,10 @@ env OPENBLAS=%{_libdir} \
|
|||||||
%{__python3} setup.py install --root %{buildroot}
|
%{__python3} setup.py install --root %{buildroot}
|
||||||
pushd %{buildroot}%{_bindir} &> /dev/null
|
pushd %{buildroot}%{_bindir} &> /dev/null
|
||||||
|
|
||||||
|
chrpath --delete %{buildroot}%{python3_sitearch}/%{name}/core/_multiarray_umath.*.so
|
||||||
|
chrpath --delete %{buildroot}%{python3_sitearch}/%{name}/linalg/lapack_lite.*.so
|
||||||
|
chrpath --delete %{buildroot}%{python3_sitearch}/%{name}/linalg/_umath_linalg.*.so
|
||||||
|
|
||||||
%check
|
%check
|
||||||
pushd doc &> /dev/null
|
pushd doc &> /dev/null
|
||||||
PYTHONPATH="%{buildroot}%{python3_sitearch}" PYTHONDONTWRITEBYTECODE=1 \
|
PYTHONPATH="%{buildroot}%{python3_sitearch}" PYTHONDONTWRITEBYTECODE=1 \
|
||||||
@ -97,15 +99,40 @@ popd &> /dev/null
|
|||||||
%{python3_sitearch}/%{name}/*
|
%{python3_sitearch}/%{name}/*
|
||||||
%{python3_sitearch}/%{name}-*.egg-info
|
%{python3_sitearch}/%{name}-*.egg-info
|
||||||
%exclude %{python3_sitearch}/%{name}/LICENSE.txt
|
%exclude %{python3_sitearch}/%{name}/LICENSE.txt
|
||||||
|
%exclude %{python3_sitearch}/%{name}/f2py
|
||||||
|
%exclude %{python3_sitearch}/%{name}/tests/
|
||||||
|
%exclude %{python3_sitearch}/%{name}/*/tests/
|
||||||
|
|
||||||
%files -n python3-numpy-f2py
|
%files -n python3-numpy-f2py
|
||||||
%{_bindir}/f2py
|
%{_bindir}/f2py
|
||||||
%{_bindir}/f2py3
|
%{_bindir}/f2py3
|
||||||
%{_bindir}/f2py3.*
|
%{_bindir}/f2py3.*
|
||||||
%{python3_sitearch}/%{name}/f2py
|
%{python3_sitearch}/%{name}/f2py
|
||||||
|
%exclude %{python3_sitearch}/%{name}/f2py/tests/
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Feb 22 2024 shixuantong <shixuantong1@huawei.com> - 1:1.24.3-3
|
||||||
|
- Type:bugfix
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:remove f2py form python3-numpy package. It is in python3-numpy-f2py
|
||||||
|
Do not pack open-source test case files
|
||||||
|
|
||||||
|
* Wed Jan 31 2024 xu_ping <707078654@qq.com> - 1:1.24.3-2
|
||||||
|
- adapted Cython upgrade version to 3.0.8
|
||||||
|
|
||||||
|
* Wed Jul 19 2023 xu_ping <707078654@qq.com> - 1:1.24.3-1
|
||||||
|
- Upgrade to 1.24.3
|
||||||
|
|
||||||
|
* Fri Feb 17 2023 wulei <wulei80@h-partners.com> - 1:1.21.4-6
|
||||||
|
- Delete rpath
|
||||||
|
|
||||||
|
* Mon Nov 14 2022 zhaozhen <zhaozhen@loongson.cn> - 1.21.4-5
|
||||||
|
- Type:feature
|
||||||
|
- CVE:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:Add loongarch64 support
|
||||||
|
|
||||||
* Tue May 31 2022 huangduirong <huangduirong@huawei.com> - 1.21.4-4
|
* Tue May 31 2022 huangduirong <huangduirong@huawei.com> - 1.21.4-4
|
||||||
- Type:CVE
|
- Type:CVE
|
||||||
- ID:CVE-2021-34141
|
- ID:CVE-2021-34141
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user