Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-gmpy2 for openSUSE:Factory 
checked in at 2024-01-25 18:41:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-gmpy2 (Old)
 and      /work/SRC/openSUSE:Factory/.python-gmpy2.new.1815 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-gmpy2"

Thu Jan 25 18:41:22 2024 rev:8 rq:1141363 version:2.1.5

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-gmpy2/python-gmpy2.changes        
2023-10-01 21:22:49.313764843 +0200
+++ /work/SRC/openSUSE:Factory/.python-gmpy2.new.1815/python-gmpy2.changes      
2024-01-25 18:41:27.719206631 +0100
@@ -1,0 +2,7 @@
+Thu Jan 25 01:40:11 UTC 2024 - Steve Kowalik <[email protected]>
+
+- Add patch support-python-312.patch:
+  * Support Python 3.12 changes.
+- Switch to pyproject macros.
+
+-------------------------------------------------------------------

New:
----
  support-python-312.patch

BETA DEBUG BEGIN:
  New:
- Add patch support-python-312.patch:
  * Support Python 3.12 changes.
BETA DEBUG END:

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

Other differences:
------------------
++++++ python-gmpy2.spec ++++++
--- /var/tmp/diff_new_pack.EismKc/_old  2024-01-25 18:41:28.459233033 +0100
+++ /var/tmp/diff_new_pack.EismKc/_new  2024-01-25 18:41:28.459233033 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-gmpy2
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -28,8 +28,12 @@
 Patch0:         mpfr421.patch
 # PATCH-FIX-UPSTREAM file included in 
https://github.com/aleaxit/gmpy/issues/418#issuecomment-1706721394
 Patch1:         gmpy2_cache.c.diff
+# PATCH-FIX-UPSTREAM included in https://github.com/aleaxit/gmpy/issues/446
+Patch2:         support-python-312.patch
 BuildRequires:  %{python_module devel}
+BuildRequires:  %{python_module pip}
 BuildRequires:  %{python_module setuptools}
+BuildRequires:  %{python_module wheel}
 BuildRequires:  fdupes
 BuildRequires:  gmp-devel
 BuildRequires:  mpc-devel
@@ -51,10 +55,10 @@
 
 %build
 export CFLAGS="%{optflags}"
-%python_build
+%pyproject_wheel
 
 %install
-%python_install
+%pyproject_install
 %python_expand %fdupes %{buildroot}%{$python_sitearch}
 
 %check
@@ -69,5 +73,5 @@
 %doc README
 %license COPYING COPYING.LESSER
 %{python_sitearch}/gmpy2
-%{python_sitearch}/gmpy2-%{version}*-info
+%{python_sitearch}/gmpy2-%{version}.dist-info
 

++++++ support-python-312.patch ++++++
diff --git a/src/gmpy2_convert.h b/src/gmpy2_convert.h
index f887d47..3e8cb2b 100644
--- a/src/gmpy2_convert.h
+++ b/src/gmpy2_convert.h
@@ -142,6 +142,27 @@ extern "C" {
 #define IS_TYPE_COMPLEX_ONLY(x)     ((x > OBJ_TYPE_REAL) && \
                                      (x < OBJ_TYPE_COMPLEX))
 
+/* Compatibility macros (to work with PyLongObject internals).
+ */
+
+#if PY_VERSION_HEX >= 0x030C0000
+#  define TAG_FROM_SIGN_AND_SIZE(is_neg, size) ((is_neg?2:(size==0)) | 
(((size_t)size) << 3))
+#  define _PyLong_SetSignAndDigitCount(obj, is_neg, size) 
(obj->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(is_neg, size))
+#elif PY_VERSION_HEX >= 0x030900A4
+#  define _PyLong_SetSignAndDigitCount(obj, is_neg, size) (Py_SET_SIZE(obj, 
(is_neg?-1:1)*size))
+#else
+#  define _PyLong_SetSignAndDigitCount(obj, is_neg, size) (Py_SIZE(obj) = 
(is_neg?-1:1)*size)
+#endif
+
+#if PY_VERSION_HEX >= 0x030C0000
+#  define GET_OB_DIGIT(obj) obj->long_value.ob_digit
+#  define _PyLong_IsNegative(obj) ((obj->long_value.lv_tag & 3) == 2)
+#  define _PyLong_DigitCount(obj) (obj->long_value.lv_tag >> 3)
+#else
+#  define GET_OB_DIGIT(obj) obj->ob_digit
+#  define _PyLong_IsNegative(obj) (Py_SIZE(obj) < 0)
+#  define _PyLong_DigitCount(obj) (_PyLong_IsNegative(obj)? 
-Py_SIZE(obj):Py_SIZE(obj))
+#endif
 
 /* Since the macros are used in gmpy2's codebase, these functions are skipped
  * until they are needed for the C API in the future.
diff --git a/src/gmpy2_convert_gmp.c b/src/gmpy2_convert_gmp.c
index cf0891e..8b8df81 100644
--- a/src/gmpy2_convert_gmp.c
+++ b/src/gmpy2_convert_gmp.c
@@ -59,33 +59,24 @@ GMPy_MPZ_From_PyIntOrLong(PyObject *obj, CTXT_Object 
*context)
     }
 #endif
 
-    switch (Py_SIZE(templong)) {
-    case -1:
-        mpz_set_si(result->z, -(sdigit)templong->ob_digit[0]);
+    len = _PyLong_DigitCount(templong);
+    negative = _PyLong_IsNegative(templong);
+
+    switch (len) {
+    case 1:
+        mpz_set_si(result->z, (sdigit)GET_OB_DIGIT(templong)[0]);
         break;
     case 0:
         mpz_set_si(result->z, 0);
         break;
-    case 1:
-        mpz_set_si(result->z, templong->ob_digit[0]);
-        break;
     default:
-        mpz_set_si(result->z, 0);
-
-        if (Py_SIZE(templong) < 0) {
-            len = - Py_SIZE(templong);
-            negative = 1;
-        } else {
-            len = Py_SIZE(templong);
-            negative = 0;
-        }
-
-        mpz_import(result->z, len, -1, sizeof(templong->ob_digit[0]), 0,
-                   sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, 
templong->ob_digit);
+        mpz_import(result->z, len, -1, sizeof(GET_OB_DIGIT(templong)[0]), 0,
+                   sizeof(GET_OB_DIGIT(templong)[0])*8 - PyLong_SHIFT,
+                   GET_OB_DIGIT(templong));
+    }
 
-        if (negative) {
-            mpz_neg(result->z, result->z);
-        }
+    if (negative) {
+        mpz_neg(result->z, result->z);
     }
     return result;
 }
@@ -105,33 +96,24 @@ mpz_set_PyIntOrLong(mpz_t z, PyObject *obj)
     }
 #endif
 
-    switch (Py_SIZE(templong)) {
-    case -1:
-        mpz_set_si(z, -(sdigit)templong->ob_digit[0]);
+    len = _PyLong_DigitCount(templong);
+    negative = _PyLong_IsNegative(templong);
+
+    switch (len) {
+    case 1:
+        mpz_set_si(z, (sdigit)GET_OB_DIGIT(templong)[0]);
         break;
     case 0:
         mpz_set_si(z, 0);
         break;
-    case 1:
-        mpz_set_si(z, templong->ob_digit[0]);
-        break;
     default:
-        mpz_set_si(z, 0);
-
-        if (Py_SIZE(templong) < 0) {
-            len = - Py_SIZE(templong);
-            negative = 1;
-        } else {
-            len = Py_SIZE(templong);
-            negative = 0;
-        }
-
-        mpz_import(z, len, -1, sizeof(templong->ob_digit[0]), 0,
-                   sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, 
templong->ob_digit);
+        mpz_import(z, len, -1, sizeof(GET_OB_DIGIT(templong)[0]), 0,
+                   sizeof(GET_OB_DIGIT(templong)[0])*8 - PyLong_SHIFT,
+                   GET_OB_DIGIT(templong));
+    }
 
-        if (negative) {
-            mpz_neg(z, z);
-        }
+    if (negative) {
+        mpz_neg(z, z);
     }
     return;
 }
@@ -186,12 +168,7 @@ GMPy_PyLong_From_MPZ(MPZ_Object *obj, CTXT_Object *context)
 
     /* Assume gmp uses limbs as least as large as the builtin longs do */
 
-    if (mpz_sgn(obj->z) < 0) {
-        negative = 1;
-    } else {
-        negative = 0;
-    }
-
+    negative = mpz_sgn(obj->z) < 0;
     size = (mpz_sizeinbase(obj->z, 2) + PyLong_SHIFT - 1) / PyLong_SHIFT;
 
     if (!(result = _PyLong_New(size))) {
@@ -200,31 +177,20 @@ GMPy_PyLong_From_MPZ(MPZ_Object *obj, CTXT_Object 
*context)
         /* LCOV_EXCL_STOP */
     }
 
-    mpz_export(result->ob_digit, &count, -1, sizeof(result->ob_digit[0]), 0,
-               sizeof(result->ob_digit[0])*8 - PyLong_SHIFT, obj->z);
+    mpz_export(GET_OB_DIGIT(result), &count, -1, 
sizeof(GET_OB_DIGIT(result)[0]), 0,
+               sizeof(GET_OB_DIGIT(result)[0])*8 - PyLong_SHIFT, obj->z);
 
     if (count == 0) {
-        result->ob_digit[0] = 0;
+        GET_OB_DIGIT(result)[0] = 0;
     }
 
     /* long_normalize() is file-static so we must reimplement it */
     /* longobjp = long_normalize(longobjp); */
-    while ((size>0) && (result->ob_digit[size-1] == 0)) {
+    while ((size>0) && (GET_OB_DIGIT(result)[size-1] == 0)) {
         size--;
     }
-#if PY_VERSION_HEX >= 0x030900A4
-    Py_SET_SIZE(result, size);
-#else
-    Py_SIZE(result) = size;
-#endif
 
-    if (negative) {
-#if PY_VERSION_HEX >= 0x030900A4
-        Py_SET_SIZE(result, - Py_SIZE(result));
-#else
-        Py_SIZE(result) = - Py_SIZE(result);
-#endif
-    }
+    _PyLong_SetSignAndDigitCount(result, negative, size);
     return (PyObject*)result;
 }
 
@@ -476,33 +442,24 @@ GMPy_XMPZ_From_PyIntOrLong(PyObject *obj, CTXT_Object 
*context)
     }
 #endif
 
-    switch (Py_SIZE(templong)) {
-    case -1:
-        mpz_set_si(result->z, -(sdigit)templong->ob_digit[0]);
+    len = _PyLong_DigitCount(templong);
+    negative = _PyLong_IsNegative(templong);
+
+    switch (len) {
+    case 1:
+        mpz_set_si(result->z, (sdigit)GET_OB_DIGIT(templong)[0]);
         break;
     case 0:
         mpz_set_si(result->z, 0);
         break;
-    case 1:
-        mpz_set_si(result->z, templong->ob_digit[0]);
-        break;
     default:
-        mpz_set_si(result->z, 0);
-
-        if (Py_SIZE(templong) < 0) {
-            len = - Py_SIZE(templong);
-            negative = 1;
-        } else {
-            len = Py_SIZE(templong);
-            negative = 0;
-        }
-
-        mpz_import(result->z, len, -1, sizeof(templong->ob_digit[0]), 0,
-                   sizeof(templong->ob_digit[0])*8 - PyLong_SHIFT, 
templong->ob_digit);
+        mpz_import(result->z, len, -1, sizeof(GET_OB_DIGIT(templong)[0]), 0,
+                   sizeof(GET_OB_DIGIT(templong)[0])*8 - PyLong_SHIFT,
+                   GET_OB_DIGIT(templong));
+    }
 
-        if (negative) {
-            mpz_neg(result->z, result->z);
-        }
+    if (negative) {
+        mpz_neg(result->z, result->z);
     }
     return result;
 }
@@ -639,7 +596,7 @@ GMPy_MPQ_From_PyStr(PyObject *s, int base, CTXT_Object 
*context)
     }
 
     cp = PyBytes_AsString(ascii_str);
-    
+
     {
         char *whereslash = strchr((char*)cp, '/');
         char *wheredot = strchr((char*)cp, '.');
diff --git a/src/gmpy2_convert_utils.c b/src/gmpy2_convert_utils.c
index d676eaf..8908d17 100644
--- a/src/gmpy2_convert_utils.c
+++ b/src/gmpy2_convert_utils.c
@@ -123,7 +123,7 @@ static unsigned long
 GMPy_Integer_AsUnsignedLongWithType_v2(PyObject *x, int xtype)
 {
     if IS_TYPE_PyInteger(xtype) {
-        if (Py_SIZE(x) < 0) {
+        if (_PyLong_IsNegative(((PyLongObject*)x))) {
             VALUE_ERROR("n must be > 0");
             return (unsigned long)-1;
         }

Reply via email to