From de38bac21e276c6dba95b8b33f7457a0ac56bdeb Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 25 Oct 2022 19:43:53 -0700 Subject: [PATCH] src/sage: Apply python-3.11.patch from https://github.com/void-linux/void-packages/commit/6229f313450ecae88743b4d5e99da2ed4de44e07 --- src/sage/cpython/cython_metaclass.h | 2 +- src/sage/libs/gmp/pylong.pyx | 8 +++----- src/sage/symbolic/ginac/numeric.cpp | 1 - 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/sage/cpython/cython_metaclass.h b/src/sage/cpython/cython_metaclass.h index cc620a4dac7..6487342b71e 100644 --- a/src/sage/cpython/cython_metaclass.h +++ b/src/sage/cpython/cython_metaclass.h @@ -66,7 +66,7 @@ static CYTHON_INLINE int Sage_PyType_Ready(PyTypeObject* t) } /* Now, set t.__class__ to metaclass */ - Py_TYPE(t) = metaclass; + Py_SET_TYPE(t, metaclass); PyType_Modified(t); } else diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx index 388be32c55e..e772b60e3e0 100644 --- a/src/sage/libs/gmp/pylong.pyx +++ b/src/sage/libs/gmp/pylong.pyx @@ -32,7 +32,7 @@ from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT from .mpz cimport * cdef extern from *: - Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object) + void Py_SET_SIZE(object, Py_ssize_t) int hash_bits """ #ifdef _PyHASH_BITS _PyHASH_BITS /* Python 3 */ @@ -57,10 +57,8 @@ cdef mpz_get_pylong_large(mpz_srcptr z): mpz_export(L.ob_digit, NULL, -1, sizeof(digit), 0, PyLong_nails, z) if mpz_sgn(z) < 0: - # Set correct size (use a pointer to hack around Cython's - # non-support for lvalues). - sizeptr = Py_SIZE_PTR(L) - sizeptr[0] = -pylong_size + # Set correct size + Py_SET_SIZE(L, -pylong_size) return L diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp index 22060441760..b40ed64edb5 100644 --- a/src/sage/symbolic/ginac/numeric.cpp +++ b/src/sage/symbolic/ginac/numeric.cpp @@ -52,7 +52,6 @@ #define register #define PY_SSIZE_T_CLEAN #include -#include #include "flint/fmpz.h" #include "flint/fmpz_factor.h" -- 2.38.1