[PATCH gpgmepy] Drop Python 2 compatibility

Yaakov Selkowitz yselkowi at redhat.com
Thu Oct 8 14:38:16 CEST 2026


SWIG 4.5 drops compatibility with Python 2, along with the macros that
allowed this to build with Python 3.
---
 gpgme.i | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/gpgme.i b/gpgme.i
index 2b4a0c0..fb2f04f 100644
--- a/gpgme.i
+++ b/gpgme.i
@@ -94,8 +94,8 @@
             }
           $1[i] = PyBytes_AsString(pyVector[i]);
         }
-      else if (PyString_Check(o))
-	$1[i] = PyString_AsString(o);
+      else if (PyBytes_Check(o))
+	$1[i] = PyBytes_AsString(o);
       else {
 	PyErr_Format(PyExc_TypeError,
                      "arg %d: list must contain only str or bytes, got %s "
@@ -315,10 +315,6 @@
 %typemap(in) ssize_t, gpgme_error_t, gpgme_err_code_t, gpgme_err_source_t, gpg_error_t {
   if (PyLong_Check($input))
     $1 = PyLong_AsLong($input);
-#if PY_MAJOR_VERSION < 3
-  else if (PyInt_Check($input))
-    $1 = PyInt_AsLong($input);
-#endif
   else {
     PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
     return NULL;
@@ -339,10 +335,6 @@
     $1 = PyLong_AsLongLong($input);
 #else
     $1 = PyLong_AsLong($input);
-#endif
-#if PY_MAJOR_VERSION < 3
-  else if (PyInt_Check($input))
-    $1 = PyInt_AsLong($input);
 #endif
   else {
     PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
@@ -356,10 +348,6 @@
     long tmp$argnum;
     if (PyLong_Check($input))
       tmp$argnum = PyLong_AsLong($input);
-#if PY_MAJOR_VERSION < 3
-    else if (PyInt_Check($input))
-      tmp$argnum = PyInt_AsLong($input);
-#endif
     else
       {
         PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
-- 
2.55.0



More information about the Gnupg-devel mailing list