Fix FTBFS with Python 3.12

This commit is contained in:
Scott Talbert 2023-07-05 16:15:40 -04:00
parent 92d66e8423
commit af3d0b491e
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From b0872b858e2e6ebc394e95c81a024dcf1573c690 Mon Sep 17 00:00:00 2001
From: Ralf Gommers <ralf.gommers@gmail.com>
Date: Mon, 19 Jun 2023 11:07:19 +0200
Subject: [PATCH] TST: skip refcount related tests on py312
Python 3.12 has immortal refcounts; the initial and final
values will be the same when accessing `sys.getrefcount` inside a
test.
Closes gh-23986
---
numpy/core/tests/test_dtype.py | 5 +++++
numpy/core/tests/test_regression.py | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index 454bcfa7cc1..9c88ddb5cd7 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -755,6 +755,11 @@ def iter_struct_object_dtypes():
yield pytest.param(dt, p, 12, obj, id="<structured subarray 2>")
+@pytest.mark.skipif(
+ sys.version_info >= (3, 12),
+ reason="Python 3.12 has immortal refcounts, this test will no longer "
+ "work. See gh-23986"
+)
@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
class TestStructuredObjectRefcounting:
"""These tests cover various uses of complicated structured types which
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index e415ecccf9f..35763f843da 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1465,6 +1465,10 @@ def test_structured_arrays_with_objects1(self):
x[x.nonzero()] = x.ravel()[:1]
assert_(x[0, 1] == x[0, 0])
+ @pytest.mark.skipif(
+ sys.version_info >= (3, 12),
+ reason="Python 3.12 has immortal refcounts, this test no longer works."
+ )
@pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts")
def test_structured_arrays_with_objects2(self):
# Ticket #1299 second test

View File

@ -20,7 +20,7 @@
Name: numpy
Version: 1.24.3
Release: 3%{?dist}
Release: 4%{?dist}
Epoch: 1
Summary: A fast multidimensional array facility for Python
@ -29,6 +29,7 @@ License: BSD-3-Clause AND Apache-2.0
URL: http://www.numpy.org/
Source0: https://github.com/%{name}/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz
Source1: https://numpy.org/doc/%(echo %{version} | cut -d. -f1-2)/numpy-html.zip
Patch0: https://github.com/numpy/numpy/commit/b0872b858e2e6ebc394e95c81a024dcf1573c690.patch
%description
NumPy is a general-purpose array-processing package designed to
@ -210,6 +211,9 @@ python3 runtests.py --no-build -- -ra -k 'not test_ppc64_ibm_double_double128 %{
%changelog
* Wed Jul 05 2023 Scott Talbert <swt@techie.net> - 1:1.24.3-4
- Fix FTBFS with Python 3.12
* Fri Jun 16 2023 Python Maint <python-maint@redhat.com> - 1:1.24.3-3
- Rebuilt for Python 3.12