| @@ -2,7 +2,7 @@ CFLAGS = -g | |||||
| INCLUDE = -I/usr/include -I. | INCLUDE = -I/usr/include -I. | ||||
| LIBS = -larchive | LIBS = -larchive | ||||
| DEFINES = -DPyUnicode_AS_STRING=PyUnicode_AS_DATA | |||||
| #DEFINES = -DPyUnicode_AS_STRING=PyUnicode_AS_DATA | |||||
| PYVER ?= 3.9 | PYVER ?= 3.9 | ||||
| all: __libarchive.so | all: __libarchive.so | ||||
| @@ -521,13 +521,14 @@ extern const char *archive_error_string(struct archive *); | |||||
| %inline %{ | %inline %{ | ||||
| PyObject *archive_read_data_into_str(struct archive *archive, int len) { | PyObject *archive_read_data_into_str(struct archive *archive, int len) { | ||||
| PyObject *str = NULL; | PyObject *str = NULL; | ||||
| if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { | if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { | ||||
| PyErr_SetString(PyExc_MemoryError, "could not allocate string."); | PyErr_SetString(PyExc_MemoryError, "could not allocate string."); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { | |||||
| if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); | PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| @@ -3193,13 +3193,14 @@ SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) | |||||
| } | } | ||||
| PyObject *archive_read_data_into_str(struct archive *archive, int len) { | PyObject *archive_read_data_into_str(struct archive *archive, int len) { | ||||
| PyObject *str = NULL; | PyObject *str = NULL; | ||||
| if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { | if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { | ||||
| PyErr_SetString(PyExc_MemoryError, "could not allocate string."); | PyErr_SetString(PyExc_MemoryError, "could not allocate string."); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if (len != archive_read_data(archive, PyString_AS_STRING(str), len)) { | |||||
| if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { | |||||
| PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); | PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||