commit:     75de7f050246aaad0bf29cd909fc729b7d8fe417
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 13 13:13:31 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jun 13 13:14:18 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=75de7f05

dev-python/m2crypto: Enable py3.10

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../m2crypto/files/m2crypto-0.37.1-py310.patch     | 119 +++++++++++++++++++++
 dev-python/m2crypto/m2crypto-0.37.1-r1.ebuild      |   3 +-
 2 files changed, 121 insertions(+), 1 deletion(-)

diff --git a/dev-python/m2crypto/files/m2crypto-0.37.1-py310.patch 
b/dev-python/m2crypto/files/m2crypto-0.37.1-py310.patch
new file mode 100644
index 00000000000..f9be349fc3d
--- /dev/null
+++ b/dev-python/m2crypto/files/m2crypto-0.37.1-py310.patch
@@ -0,0 +1,119 @@
+diff --git a/SWIG/_bio.i b/SWIG/_bio.i
+index 84b76b3..6c090a4 100644
+--- a/SWIG/_bio.i
++++ b/SWIG/_bio.i
+@@ -246,8 +246,8 @@ PyObject *bio_set_cipher(BIO *b, EVP_CIPHER *c, PyObject 
*key, PyObject *iv, int
+     const void *kbuf, *ibuf;
+     Py_ssize_t klen, ilen;
+ 
+-    if ((PyObject_AsReadBuffer(key, &kbuf, &klen) == -1)
+-        || (PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1))
++    if ((m2_PyObject_AsReadBuffer(key, &kbuf, &klen) == -1)
++        || (m2_PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1))
+         return NULL;
+ 
+     BIO_set_cipher(b, (const EVP_CIPHER *)c,
+diff --git a/SWIG/_ec.i b/SWIG/_ec.i
+index f47d593..a492f6f 100644
+--- a/SWIG/_ec.i
++++ b/SWIG/_ec.i
+@@ -466,7 +466,7 @@ EC_KEY* ec_key_from_pubkey_der(PyObject *pubkey) {
+     const unsigned char *tempBuf;
+     EC_KEY *keypair;
+ 
+-    if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1)
++    if (m2_PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1)
+     {
+         return NULL;
+     }
+@@ -486,7 +486,7 @@ EC_KEY* ec_key_from_pubkey_params(int nid, PyObject 
*pubkey) {
+     const unsigned char *tempBuf;
+     EC_KEY *keypair;
+ 
+-    if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1)
++    if (m2_PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1)
+     {
+         return NULL;
+     }
+diff --git a/SWIG/_lib.i b/SWIG/_lib.i
+index 954e99b..351134b 100644
+--- a/SWIG/_lib.i
++++ b/SWIG/_lib.i
+@@ -137,8 +137,8 @@ m2_PyObject_AsReadBuffer(PyObject * obj, const void 
**buffer,
+           len = view.len;
+       }
+     } else {
+-      if ((ret = PyObject_AsReadBuffer(obj, buffer, &len)) != 0)
+-          return ret;
++    PyErr_SetString(PyExc_TypeError, "expected a readable buffer object");
++      return -1;
+     }
+     if (len > INT_MAX) {
+       m2_PyBuffer_Release(obj, &view);
+@@ -171,11 +171,8 @@ static int m2_PyObject_GetBufferInt(PyObject *obj, 
Py_buffer *view, int flags)
+     if (PyObject_CheckBuffer(obj))
+         ret = PyObject_GetBuffer(obj, view, flags);
+     else {
+-        const void *buf;
+-
+-        ret = PyObject_AsReadBuffer(obj, &buf, &view->len);
+-        if (ret == 0)
+-            view->buf = (void *)buf;
++        PyErr_SetString(PyExc_TypeError, "expected a readable buffer object");
++        return -1;
+     }
+     if (ret)
+         return ret;
+@@ -633,7 +630,7 @@ BIGNUM *hex_to_bn(PyObject *value) {
+         }
+     }
+     else {
+-        if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1)
++        if (m2_PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1)
+             return NULL;
+     }
+ 
+@@ -665,7 +662,7 @@ BIGNUM *dec_to_bn(PyObject *value) {
+         }
+     }
+     else {
+-        if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1)
++        if (m2_PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1)
+             return NULL;
+     }
+ 
+diff --git a/SWIG/_rc4.i b/SWIG/_rc4.i
+index eb4747e..6af2dc6 100644
+--- a/SWIG/_rc4.i
++++ b/SWIG/_rc4.i
+@@ -46,7 +46,7 @@ PyObject *rc4_update(RC4_KEY *key, PyObject *in) {
+     Py_ssize_t len;
+     void *out;
+ 
+-    if (PyObject_AsReadBuffer(in, &buf, &len) == -1)
++    if (m2_PyObject_AsReadBuffer(in, &buf, &len) == -1)
+         return NULL;
+ 
+     if (!(out = PyMem_Malloc(len))) {
+diff --git a/SWIG/_util.i b/SWIG/_util.i
+index bc2ee61..18e446a 100644
+--- a/SWIG/_util.i
++++ b/SWIG/_util.i
+@@ -22,7 +22,7 @@ PyObject *util_hex_to_string(PyObject *blob) {
+     char *ret;
+     Py_ssize_t len;
+ 
+-    if (PyObject_AsReadBuffer(blob, &buf, &len) == -1)
++    if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1)
+         return NULL;
+ 
+     ret = hex_to_string((unsigned char *)buf, len);
+@@ -44,7 +44,7 @@ PyObject *util_string_to_hex(PyObject *blob) {
+     Py_ssize_t len0;
+     long len;
+ 
+-    if (PyObject_AsReadBuffer(blob, &buf, &len0) == -1)
++    if (m2_PyObject_AsReadBuffer(blob, &buf, &len0) == -1)
+         return NULL;
+ 
+     len = len0;

diff --git a/dev-python/m2crypto/m2crypto-0.37.1-r1.ebuild 
b/dev-python/m2crypto/m2crypto-0.37.1-r1.ebuild
index b6c17695032..86a23528664 100644
--- a/dev-python/m2crypto/m2crypto-0.37.1-r1.ebuild
+++ b/dev-python/m2crypto/m2crypto-0.37.1-r1.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-PYTHON_COMPAT=( python3_{7..9} )
+PYTHON_COMPAT=( python3_{8..10} )
 PYTHON_REQ_USE="threads(+)"
 
 inherit distutils-r1 toolchain-funcs
@@ -31,6 +31,7 @@ DEPEND="${RDEPEND}"
 
 PATCHES=(
        "${FILESDIR}/${P}-openssl-fixes.patch"
+       "${FILESDIR}/${P}-py310.patch"
 )
 
 swig_define() {

Reply via email to