diff --git a/python-crypto-2.6.1-python3.12.patch b/python-crypto-2.6.1-python3.12.patch new file mode 100644 index 0000000..914c638 --- /dev/null +++ b/python-crypto-2.6.1-python3.12.patch @@ -0,0 +1,61 @@ +--- src/_fastmath.c ++++ src/_fastmath.c +@@ -70,11 +70,11 @@ longObjToMPZ (mpz_t m, PyLongObject * p) + mpz_init (temp); + mpz_init (temp2); + #ifdef IS_PY3K +- if (p->ob_base.ob_size > 0) { +- size = p->ob_base.ob_size; ++ if (Py_SIZE(p) > 0) { ++ size = Py_SIZE(p); + negative = 1; + } else { +- size = -p->ob_base.ob_size; ++ size = -Py_SIZE(p); + negative = -1; + } + #else +@@ -89,7 +89,11 @@ longObjToMPZ (mpz_t m, PyLongObject * p) + mpz_set_ui (m, 0); + for (i = 0; i < size; i++) + { ++#if PY_VERSION_HEX < 0x030C0000 + mpz_set_ui (temp, p->ob_digit[i]); ++#else ++ mpz_set_ui (temp, p->long_value.ob_digit[i]); ++#endif + #ifdef IS_PY3K + mpz_mul_2exp (temp2, temp, PyLong_SHIFT * i); + #else +@@ -123,7 +127,11 @@ mpzToLongObj (mpz_t m) + 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); +@@ -131,11 +139,19 @@ mpzToLongObj (mpz_t m) + #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 < 0x03090000 + l->ob_base.ob_size = i * sgn; + #else ++ Py_SET_SIZE(l, (Py_ssize_t)(i * sgn)); ++#endif ++#else + l->ob_size = i * sgn; + #endif + mpz_clear (temp); diff --git a/python-crypto.spec b/python-crypto.spec index 1264476..1ca9648 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: 42%{?dist} +Release: 43%{?dist} # Mostly Public Domain apart from parts of HMAC.py and setup.py, which are Python License: Public Domain and Python URL: http://www.pycrypto.org/ @@ -25,6 +25,7 @@ Patch9: python-crypto-2.6.1-python3.11.patch 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 BuildRequires: coreutils BuildRequires: findutils BuildRequires: gcc @@ -112,6 +113,9 @@ rm -rf src/libtom # Get rid of a SyntaxWarning in test_random.py %patch12 +# Fix Python 3.12 compatibility +%patch13 + %build %global optflags %{optflags} -fno-strict-aliasing %py3_build @@ -135,6 +139,9 @@ PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} pct-speedtest.py %{python3_sitearch}/pycrypto-%{version}-py3.*.egg-info %changelog +* Mon Mar 13 2023 Paul Howarth - 2.6.1-43 +- Fix Python 3.12 compatibility (rhbz#2177718) + * Fri Jan 20 2023 Fedora Release Engineering - 2.6.1-42 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild