michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

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

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