diff options
author | Tim Burke <tim.burke@gmail.com> | 2021-05-10 18:07:03 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2021-05-10 18:10:44 -0700 |
commit | a7bf798b1000c037bcf9f54f4deb875aba08ce51 (patch) | |
tree | c69bdf8e5678fa39bbb85fbd460de199ecf90f0d | |
parent | 5355c0268b3e633a91ae912ff394440ea3fc3f7d (diff) | |
download | pyeclib-a7bf798b1000c037bcf9f54f4deb875aba08ce51.tar.gz |
Use Py_ssize_t when calling PyArg_Parse
This has been available since Python 2.5, and our old int-based approach
stopped working in Python 3.10. From https://bugs.python.org/issue36381:
Raise warning for # use without PY_SSIZE_T_CLEAN.
* 3.8: PendingDeprecationWarning
* 3.9: DeprecationWarning
* 3.10 (or 4.0): Remove PY_SSIZE_T_CLEAN and use Py_ssize_t always
Change-Id: I5394268aaf4c409a75f795a44c092fd5101178cd
-rw-r--r-- | src/c/pyeclib_c/pyeclib_c.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/c/pyeclib_c/pyeclib_c.c b/src/c/pyeclib_c/pyeclib_c.c index 4e2646c..1968b80 100644 --- a/src/c/pyeclib_c/pyeclib_c.c +++ b/src/c/pyeclib_c/pyeclib_c.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <paths.h> +#define PY_SSIZE_T_CLEAN #include <Python.h> #include <math.h> #include <bytesobject.h> @@ -492,7 +493,7 @@ pyeclib_c_encode(PyObject *self, PyObject *args) char **encoded_parity = NULL; /* array of m parity buffers */ PyObject *list_of_strips = NULL; /* list of encoded strips to return */ char *data; /* param, data buffer to encode */ - int data_len; /* param, length of data buffer */ + Py_ssize_t data_len; /* param, length of data buffer */ uint64_t fragment_len; /* length, in bytes of the fragments */ int i; /* a counter */ int ret = 0; @@ -1040,7 +1041,7 @@ pyeclib_c_get_metadata(PyObject *self, PyObject *args) char *fragment = NULL; /* param, fragment from caller */ fragment_metadata_t c_fragment_metadata; /* structure to hold metadata */ PyObject *fragment_metadata = NULL; /* metadata object to return */ - int fragment_len; /* fragment length */ + Py_ssize_t fragment_len; /* fragment length */ int formatted; /* format the metadata in a dict */ int ret; |