From a5f43e4a5810eb9a940d5827b191c5e93ff5e47d Mon Sep 17 00:00:00 2001 From: Richard Young Date: Tue, 16 Nov 2021 13:36:30 -0500 Subject: [PATCH] Attempt to fix API for 3.10 compatibility --- libarchive/_libarchive_wrap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index bd56746..4701b3e 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -760,7 +760,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #define PyString_Size(str) PyBytes_Size(str) #define PyString_InternFromString(key) PyUnicode_InternFromString(key) #define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE -#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define PyString_AS_STRING(x) PyUnicode_AsUTF8(x) #define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) #endif @@ -3199,7 +3199,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { + if (len != archive_read_data(archive, (void*)PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } @@ -3208,7 +3208,7 @@ PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *archive_write_data_from_str(struct archive *archive, PyObject *str) { int len = PyString_Size(str); - if (!archive_write_data(archive, PyString_AS_STRING(str), len)) { + if (!archive_write_data(archive, (const void *)PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not write requested data."); return NULL; }