dev-python/m2crypto: Enable py3.10

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2021-06-13 15:13:31 +02:00
parent 3b809bc440
commit 75de7f0502
2 changed files with 121 additions and 1 deletions

View File

@@ -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;

View File

@@ -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() {