Blame SOURCES/0004-Bump-the-minimum-Python-version-requirement-to-2.7.patch

f6faf3
From 0b1456ed4c00a021389acea4b6b10d475986b660 Mon Sep 17 00:00:00 2001
f6faf3
Message-Id: <0b1456ed4c00a021389acea4b6b10d475986b660.1571920849.git.pmatilai@redhat.com>
f6faf3
In-Reply-To: <6b6c4d881dc6fc99f949dac4aaf9a513542f9956.1571920849.git.pmatilai@redhat.com>
f6faf3
References: <6b6c4d881dc6fc99f949dac4aaf9a513542f9956.1571920849.git.pmatilai@redhat.com>
f6faf3
From: Panu Matilainen <pmatilai@redhat.com>
f6faf3
Date: Thu, 4 Oct 2018 18:05:37 +0300
f6faf3
Subject: [PATCH 4/5] Bump the minimum Python version requirement to 2.7
f6faf3
f6faf3
Older Python versions are long since past their EOL, we don't need to
f6faf3
support them either. Python 2.7 is also the least incompatible version
f6faf3
compared to Python 3, going forward. Nuke the now unnecessary compat
f6faf3
macros.
f6faf3
f6faf3
(cherry picked from commit 3f3cb3eabf7bb49dcc6e691601f89500b3487e06)
f6faf3
---
f6faf3
 configure.ac          |  2 +-
f6faf3
 python/header-py.c    |  4 ++--
f6faf3
 python/rpmsystem-py.h | 33 ---------------------------------
f6faf3
 python/spec-py.c      |  2 +-
f6faf3
 4 files changed, 4 insertions(+), 37 deletions(-)
f6faf3
f6faf3
diff --git a/configure.ac b/configure.ac
f6faf3
index 34ea85f9f..4d1a48e5f 100644
f6faf3
--- a/configure.ac
f6faf3
+++ b/configure.ac
f6faf3
@@ -800,7 +800,7 @@ esac],
f6faf3
 
f6faf3
 WITH_PYTHON_SUBPACKAGE=0
f6faf3
 AS_IF([test "$enable_python" = yes],[
f6faf3
-  AM_PATH_PYTHON([2.6],[
f6faf3
+  AM_PATH_PYTHON([2.7],[
f6faf3
     PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}], [WITH_PYTHON_SUBPACKAGE=1])
f6faf3
     AC_SUBST(PYTHON_CFLAGS)
f6faf3
     AC_SUBST(PYTHON_LIB)
f6faf3
diff --git a/python/header-py.c b/python/header-py.c
f6faf3
index 628b48534..c9d54e869 100644
f6faf3
--- a/python/header-py.c
f6faf3
+++ b/python/header-py.c
f6faf3
@@ -376,8 +376,8 @@ static PyObject *hdr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
f6faf3
 
f6faf3
     if (obj == NULL) {
f6faf3
 	h = headerNew();
f6faf3
-    } else if (CAPSULE_CHECK(obj)) {
f6faf3
-	h = CAPSULE_EXTRACT(obj, "rpm._C_Header");
f6faf3
+    } else if (PyCapsule_CheckExact(obj)) {
f6faf3
+	h = PyCapsule_GetPointer(obj, "rpm._C_Header");
f6faf3
 	headerLink(h);
f6faf3
     } else if (hdrObject_Check(obj)) {
f6faf3
 	h = headerCopy(((hdrObject*) obj)->h);
f6faf3
diff --git a/python/rpmsystem-py.h b/python/rpmsystem-py.h
f6faf3
index c8423e3dc..955d60cd3 100644
f6faf3
--- a/python/rpmsystem-py.h
f6faf3
+++ b/python/rpmsystem-py.h
f6faf3
@@ -9,39 +9,6 @@
f6faf3
 #include <Python.h>
f6faf3
 #include <structmember.h>
f6faf3
 
f6faf3
-#if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) < 0x0205
f6faf3
-typedef ssize_t Py_ssize_t;
f6faf3
-typedef Py_ssize_t (*lenfunc)(PyObject *);
f6faf3
-#endif  
f6faf3
-
f6faf3
-/* Compatibility macros for Python < 2.6 */
f6faf3
-#ifndef PyVarObject_HEAD_INIT
f6faf3
-#define PyVarObject_HEAD_INIT(type, size) \
f6faf3
-	PyObject_HEAD_INIT(type) size,
f6faf3
-#endif 
f6faf3
-
f6faf3
-#ifndef Py_TYPE
f6faf3
-#define Py_TYPE(o) ((o)->ob_type)
f6faf3
-#endif
f6faf3
-
f6faf3
-#if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) < 0x0206
f6faf3
-#define PyBytes_Check PyString_Check
f6faf3
-#define PyBytes_FromString PyString_FromString
f6faf3
-#define PyBytes_FromStringAndSize PyString_FromStringAndSize
f6faf3
-#define PyBytes_Size PyString_Size
f6faf3
-#define PyBytes_AsString PyString_AsString
f6faf3
-#endif
f6faf3
-
f6faf3
-#if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) >= 0x0207
f6faf3
-#define CAPSULE_BUILD(ptr,name) PyCapsule_New(ptr, name, NULL)
f6faf3
-#define CAPSULE_CHECK(obj) PyCapsule_CheckExact(obj)
f6faf3
-#define CAPSULE_EXTRACT(obj,name) PyCapsule_GetPointer(obj, name)
f6faf3
-#else
f6faf3
-#define CAPSULE_BUILD(ptr,name) PyCObject_FromVoidPtr(ptr, NULL)
f6faf3
-#define CAPSULE_CHECK(obj) PyCObject_Check(obj)
f6faf3
-#define CAPSULE_EXTRACT(obj,name) PyCObject_AsVoidPtr(obj)
f6faf3
-#endif
f6faf3
-
f6faf3
 /* For Python 3, use the PyLong type throughout in place of PyInt */
f6faf3
 #if PY_MAJOR_VERSION >= 3
f6faf3
 #define PyInt_Check PyLong_Check
f6faf3
diff --git a/python/spec-py.c b/python/spec-py.c
f6faf3
index fa7e58928..4efdbf4bf 100644
f6faf3
--- a/python/spec-py.c
f6faf3
+++ b/python/spec-py.c
f6faf3
@@ -34,7 +34,7 @@ static PyObject *makeHeader(Header h)
f6faf3
     PyObject *rpmmod = PyImport_ImportModuleNoBlock("rpm");
f6faf3
     if (rpmmod == NULL) return NULL;
f6faf3
 
f6faf3
-    PyObject *ptr = CAPSULE_BUILD(h, "rpm._C_Header");
f6faf3
+    PyObject *ptr = PyCapsule_New(h, "rpm._C_Header", NULL);
f6faf3
     PyObject *hdr = PyObject_CallMethod(rpmmod, "hdr", "(O)", ptr);
f6faf3
     Py_XDECREF(ptr);
f6faf3
     Py_XDECREF(rpmmod);
f6faf3
-- 
f6faf3
2.21.0
f6faf3