From 07c50e4c0a33861c0ce8dbb7b2d530c2a0019cb9 Mon Sep 17 00:00:00 2001 From: Paul Howarth Date: Oct 28 2023 14:44:33 +0000 Subject: Fix Python 3.13 compatibility (rhbz#2245851) --- diff --git a/python-crypto-2.6.1-python3.13.patch b/python-crypto-2.6.1-python3.13.patch new file mode 100644 index 0000000..7202252 --- /dev/null +++ b/python-crypto-2.6.1-python3.13.patch @@ -0,0 +1,62 @@ +--- src/_fastmath.c ++++ src/_fastmath.c +@@ -134,12 +134,18 @@ longObjToMPZ (mpz_t m, PyLongObject * p) + static PyObject * + mpzToLongObj (mpz_t m) + { +- /* borrowed from gmpy */ + #ifdef IS_PY3K +- int size = (mpz_sizeinbase (m, 2) + PyLong_SHIFT - 1) / PyLong_SHIFT; ++ PyObject *retval; ++ int size = mpz_sizeinbase(m, 10) + 2; ++ char *str = malloc(size); ++ if (!str) ++ return NULL; ++ retval = PyLong_FromString(mpz_get_str(str, 10, m), NULL, 10); ++ free(str); ++ return retval; + #else ++ /* borrowed from gmpy */ + int size = (mpz_sizeinbase (m, 2) + SHIFT - 1) / SHIFT; +-#endif + int sgn; + int i; + mpz_t temp; +@@ -151,36 +157,16 @@ mpzToLongObj (mpz_t m) + mpz_mul_si(temp, m, sgn); + for (i = 0; i < size; i++) + { +-#ifdef IS_PY3K +-#if PY_VERSION_HEX < 0x030C0000 +- l->ob_digit[i] = (digit) (mpz_get_ui (temp) & PyLong_MASK); +-#else +- l->long_value.ob_digit[i] = (digit) (mpz_get_ui (temp) & PyLong_MASK); +-#endif +- mpz_fdiv_q_2exp (temp, temp, PyLong_SHIFT); +-#else + l->ob_digit[i] = (digit) (mpz_get_ui (temp) & MASK); + mpz_fdiv_q_2exp (temp, temp, SHIFT); +-#endif + } + i = size; +-#if PY_VERSION_HEX < 0x030C0000 + while ((i > 0) && (l->ob_digit[i - 1] == 0)) +-#else +- while ((i > 0) && (l->long_value.ob_digit[i - 1] == 0)) +-#endif + i--; +-#ifdef IS_PY3K +-#if PY_VERSION_HEX < 0x030C0000 +- l->ob_base.ob_size = i * sgn; +-#else +- l->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sgn, (size_t)i); +-#endif +-#else + l->ob_size = i * sgn; +-#endif + mpz_clear (temp); + return (PyObject *) l; ++#endif + } + + typedef struct diff --git a/python-crypto.spec b/python-crypto.spec index 27f70a1..78111df 100644 --- a/python-crypto.spec +++ b/python-crypto.spec @@ -7,7 +7,7 @@ Summary: Cryptography library for Python Name: python-crypto Version: 2.6.1 -Release: 47%{?dist} +Release: 48%{?dist} # Mostly LicenseRef-Fedora-Public-Domain apart from parts of HMAC.py and setup.py, which are PSF-2.0 License: LicenseRef-Fedora-Public-Domain AND PSF-2.0 URL: http://www.pycrypto.org/ @@ -26,6 +26,7 @@ Patch10: python-crypto-2.6.1-python3only.patch Patch11: python-crypto-2.6.1-no-distutils.patch Patch12: python-crypto-2.6.1-SyntaxWarning.patch Patch13: python-crypto-2.6.1-python3.12.patch +Patch14: python-crypto-2.6.1-python3.13.patch BuildRequires: coreutils BuildRequires: findutils BuildRequires: gcc @@ -116,6 +117,9 @@ rm -rf src/libtom # Fix Python 3.12 compatibility %patch -P 13 +# Fix Python 3.13 compatibility +%patch -P 14 + %build %global optflags %{optflags} -fno-strict-aliasing %py3_build @@ -139,6 +143,9 @@ PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} pct-speedtest.py %{python3_sitearch}/pycrypto-%{version}-py3.*.egg-info %changelog +* Fri Oct 27 2023 Paul Howarth - 2.6.1-48 +- Fix Python 3.13 compatibility (rhbz#2245851) + * Fri Jul 21 2023 Fedora Release Engineering - 2.6.1-47 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild