1
0

Accepting request 1177083 from home:glaubitz:branches:devel:languages:python:numeric

- Cherry-pick upstream patch to fix build with GCC 14
  * https://github.com/astropy/astropy/pull/16450.patch

OBS-URL: https://build.opensuse.org/request/show/1177083
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-astropy?expand=0&rev=122
This commit is contained in:
Matej Cepl 2024-05-27 15:03:21 +00:00 committed by Git OBS Bridge
parent dea5c9d6c9
commit b04a5b6dba
3 changed files with 151 additions and 0 deletions

143
16450.patch Normal file
View File

@ -0,0 +1,143 @@
From ce38ef47e858e86518db1aeb2f299cd9ce1a5d29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Robert?= <cr52@protonmail.com>
Date: Tue, 14 May 2024 09:59:01 +0200
Subject: [PATCH] BUG: Fix broken compilation with gcc 14: avoid implicit
conversions between ``PyObject*`` and ``PyArrayObject*`` pointer types
---
astropy/wcs/src/wcslib_celprm_wrap.c | 4 ++--
astropy/wcs/src/wcslib_prjprm_wrap.c | 27 +++++++++++++++------------
docs/changes/wcs/16450.bugfix.rst | 1 +
3 files changed, 18 insertions(+), 14 deletions(-)
create mode 100644 docs/changes/wcs/16450.bugfix.rst
diff --git a/astropy/wcs/src/wcslib_celprm_wrap.c b/astropy/wcs/src/wcslib_celprm_wrap.c
index 3694ac4efe9..a25dbf4eea6 100644
--- a/astropy/wcs/src/wcslib_celprm_wrap.c
+++ b/astropy/wcs/src/wcslib_celprm_wrap.c
@@ -164,7 +164,7 @@ static PyObject* PyCelprm_copy(PyCelprm* self)
static PyObject* PyCelprm_deepcopy(PyCelprm* self)
{
- PyCelprm* copy = PyCelprm_new(&PyCelprmType, NULL, NULL);
+ PyCelprm* copy = (PyCelprm*) PyCelprm_new(&PyCelprmType, NULL, NULL);
if (copy == NULL) return NULL;
memcpy(copy->x, self->x, sizeof(struct celprm));
@@ -321,7 +321,7 @@ static int PyCelprm_set_ref(PyCelprm* self, PyObject* value, void* closure)
return 0;
}
- PyObject* value_array = PyArray_ContiguousFromAny(value, NPY_DOUBLE, 1, 1);
+ PyArrayObject* value_array = (PyArrayObject*) PyArray_ContiguousFromAny(value, NPY_DOUBLE, 1, 1);
if (!value_array) return -1;
size = PyArray_SIZE(value_array);
diff --git a/astropy/wcs/src/wcslib_prjprm_wrap.c b/astropy/wcs/src/wcslib_prjprm_wrap.c
index 2eeda9dfb5b..7a312f3d02d 100644
--- a/astropy/wcs/src/wcslib_prjprm_wrap.c
+++ b/astropy/wcs/src/wcslib_prjprm_wrap.c
@@ -146,7 +146,7 @@ static PyObject* PyPrjprm_copy(PyPrjprm* self)
static PyObject* PyPrjprm_deepcopy(PyPrjprm* self)
{
- PyPrjprm* copy = PyPrjprm_new(&PyPrjprmType, NULL, NULL);
+ PyPrjprm* copy = (PyPrjprm*) PyPrjprm_new(&PyPrjprmType, NULL, NULL);
if (copy == NULL) return NULL;
memcpy(copy->x, self->x, sizeof(struct prjprm));
@@ -510,11 +510,12 @@ static PyObject* PyPrjprm_get_pv(PyPrjprm* self, void* closure)
int k;
Py_ssize_t size = PVN;
double *pv;
- PyObject* pv_array;
-
+ PyObject* pv_pyobj;
+ PyArrayObject* pv_array;
if (is_prj_null(self)) return NULL;
- pv_array = (PyArrayObject*) PyArray_SimpleNew(1, &size, NPY_DOUBLE);
+ pv_pyobj = PyArray_SimpleNew(1, &size, NPY_DOUBLE);
+ pv_array = (PyArrayObject*) pv_pyobj;
if (pv_array == NULL) return NULL;
pv = (double*) PyArray_DATA(pv_array);
@@ -526,7 +527,7 @@ static PyObject* PyPrjprm_get_pv(PyPrjprm* self, void* closure)
}
}
- return pv_array;
+ return pv_pyobj;
}
@@ -535,7 +536,7 @@ static int PyPrjprm_set_pv(PyPrjprm* self, PyObject* value, void* closure)
int k, modified;
npy_intp size;
double *data;
- PyObject* value_array = NULL;
+ PyArrayObject* value_array = NULL;
int skip[PVN];
if (is_prj_null(self) || is_readonly(self)) return -1;
@@ -550,7 +551,7 @@ static int PyPrjprm_set_pv(PyPrjprm* self, PyObject* value, void* closure)
return 0;
}
- value_array = PyArray_ContiguousFromAny(value, NPY_DOUBLE, 1, 1);
+ value_array = (PyArrayObject*) PyArray_ContiguousFromAny(value, NPY_DOUBLE, 1, 1);
if (!value_array) return -1;
size = PyArray_SIZE(value_array);
@@ -654,7 +655,8 @@ static PyObject* PyPrjprm_set_pvi(PyPrjprm* self, PyObject* args, PyObject* kwds
PyObject* index = NULL;
PyObject* value = NULL;
PyObject* flt_value = NULL;
- PyObject* value_array = NULL;
+ PyObject* value_array_pyobj = NULL;
+ PyArrayObject* value_array = NULL;
const char* keywords[] = { "index", "value", NULL };
PyArray_Descr* dbl_descr = PyArray_DescrNewFromType(NPY_DOUBLE);
@@ -705,9 +707,10 @@ static PyObject* PyPrjprm_set_pvi(PyPrjprm* self, PyObject* args, PyObject* kwds
}
} else {
- if (PyArray_Converter(value, &value_array) == NPY_FAIL) {
+ if (PyArray_Converter(value, &value_array_pyobj) == NPY_FAIL) {
return NULL;
}
+ value_array = (PyArrayObject*) value_array_pyobj;
size = PyArray_SIZE(value_array);
if (size != 1) {
@@ -771,11 +774,11 @@ static PyObject* PyPrjprm_get_w(PyPrjprm* self, void* closure)
Py_ssize_t size = 10;
int k;
double *w;
- PyObject* w_array;
+ PyArrayObject* w_array;
if (is_prj_null(self)) return NULL;
- w_array = (PyObject*) PyArray_SimpleNew(1, &size, NPY_DOUBLE);
+ w_array = (PyArrayObject*) PyArray_SimpleNew(1, &size, NPY_DOUBLE);
if (w_array == NULL) return NULL;
w = (double*) PyArray_DATA(w_array);
@@ -787,7 +790,7 @@ static PyObject* PyPrjprm_get_w(PyPrjprm* self, void* closure)
}
}
- return w_array;
+ return (PyObject*) w_array;
}
diff --git a/docs/changes/wcs/16450.bugfix.rst b/docs/changes/wcs/16450.bugfix.rst
new file mode 100644
index 00000000000..40eb16295ed
--- /dev/null
+++ b/docs/changes/wcs/16450.bugfix.rst
@@ -0,0 +1 @@
+Fix compilation with gcc 14, avoid implicit pointer conversions.

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon May 27 09:49:39 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Cherry-pick upstream patch to fix build with GCC 14
* https://github.com/astropy/astropy/pull/16450.patch
-------------------------------------------------------------------
Sun May 5 09:45:35 UTC 2024 - Ben Greiner <code@bnavigator.de>

View File

@ -59,6 +59,8 @@ Source: https://files.pythonhosted.org/packages/source/a/astropy/astropy
# Mark wcs headers as false positives for devel-file-in-non-devel-package
# These are used by the python files so they must be available.
Source100: python-astropy-rpmlintrc
# PATCH-FIX-UPSTREAM - BUG: fix compilation with gcc 14, avoid implicit pointer conversions
Patch: https://github.com/astropy/astropy/pull/16450.patch
# https://docs.astropy.org/en/v6.1/install.html#requirements
BuildRequires: %{python_module Cython >= 3 with %python-Cython < 3.1}
BuildRequires: %{python_module devel >= 3.9}