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

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