diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 88a2228..1dccbc6 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -524,11 +524,11 @@ extern const char *archive_error_string(struct archive *); PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; - if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { + if (!(str = PyBytes_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { + if (len != archive_read_data(archive, PyBytes_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; } diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index 61d339f..d13a0e1 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -3196,11 +3196,11 @@ SWIG_AsVal_unsigned_SS_short (PyObject * obj, unsigned short *val) PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; - if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { + if (!(str = PyBytes_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } - if (len != archive_read_data(archive, PyUnicode_AS_DATA(str), len)) { + if (len != archive_read_data(archive, PyBytes_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not read requested data."); return NULL; }