Re:[gpgmepy] swig 4.5 removes python2 support
Funda Wang via Gnupg-devel <[email protected]>
| Newsgroups | gmane.comp.encryption.gpg.devel |
|---|---|
| Message-ID | <[email protected]> |
I've proposed a patch. Hope it works correctly, especially for PyString_Check. I don't know it should be Bytes or Unicode _______________________________________________ Gnupg-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gnupg-devel
gpgme-port-to-python3-only-codebase.patch
(application/octet-stream, 1.7 KB)
From d10c43e008fa5638111c9777248d3564a7ff9add Mon Sep 17 00:00:00 2001 From: Funda Wang <[email protected]> Date: Fri, 7 Aug 2026 23:12:05 +0800 Subject: [PATCH] port to python3 only codebase --- 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.54.0