0002-Use-Python-3.2-compatible-object-hash-slot-type.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From a0a937a454b2f82eae7ed3b4436614e64ef63e2d Mon Sep 17 00:00:00 2001
  2. From: Panu Matilainen <pmatilai@redhat.com>
  3. Date: Mon, 13 Mar 2023 12:41:11 +0200
  4. Subject: [PATCH] Use Python >= 3.2 compatible object hash slot type
  5. Python 3.2 changed the object hash type to make them pointer-width on
  6. all platforms - an incompatible change but apparently 3.2 was early enough
  7. in the 3.x days for such changes: https://bugs.python.org/issue9778
  8. The hash vs pointer size mismatch has quietly been there all along but
  9. clang >= 16 started treating this as an error, causing failed builds.
  10. The fix is easy and obvious enough, but this requires us to bump the
  11. minimum Python version from 3.1 to 3.2. Which thankfully is old enough that
  12. we can do without having to care or introduce build-time compatibility
  13. workarounds.
  14. Suggested-by: Khem Raj <raj.khem@gmail.com>
  15. Upstream: 45103f84764b2a293b068eb0f59456f553ec45d8
  16. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  17. ---
  18. INSTALL | 4 ++--
  19. python/header-py.c | 4 ++--
  20. 2 files changed, 4 insertions(+), 4 deletions(-)
  21. diff --git a/INSTALL b/INSTALL
  22. index 13d0d8a83..528c1e5c0 100644
  23. --- a/INSTALL
  24. +++ b/INSTALL
  25. @@ -66,8 +66,8 @@ These are available from
  26. http://www.bzip.org
  27. http://tukaani.org/xz/
  28. -If you want to build the Python bindings to RPM library, it can be enabled
  29. -with --enable-python option to configure. You'll need to have Python >= 3.1
  30. +Python bindings to RPM library are built by default, but it can be disabled
  31. +with -DENABLE_PYTHON=OFF. You'll need to have Python >= 3.2
  32. runtime and C API development environment installed.
  33. Python is available from:
  34. http://www.python.org/
  35. diff --git a/python/header-py.c b/python/header-py.c
  36. index 0aed0c926..c15503f35 100644
  37. --- a/python/header-py.c
  38. +++ b/python/header-py.c
  39. @@ -316,9 +316,9 @@ static PyObject * hdr_dsOfHeader(PyObject * s)
  40. "(Oi)", s, RPMTAG_NEVR);
  41. }
  42. -static long hdr_hash(PyObject * h)
  43. +static Py_hash_t hdr_hash(PyObject * h)
  44. {
  45. - return (long) h;
  46. + return (Py_hash_t) h;
  47. }
  48. static PyObject * hdr_reduce(hdrObject *s)
  49. --
  50. 2.49.0