From 52b97691e0b6772d6de096f975d225d2313df1d7 Mon Sep 17 00:00:00 2001 From: Jessica Hair Date: Thu, 5 Dec 2019 14:37:06 -0500 Subject: [PATCH] Remove PyString and use PyUnicode --- libarchive/_libarchive.i | 2 +- libarchive/_libarchive_wrap.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index d3d49b1..13b2474 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -360,7 +360,7 @@ extern const char *archive_error_string(struct archive *); %inline %{ PyObject *archive_read_data_into_str(struct archive *archive, int len) { PyObject *str = NULL; - if (!(str = PyString_FromStringAndSize(NULL, len))) { + if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; } diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index c8c18bd..d7aba11 100644 --- a/libarchive/_libarchive_wrap.c +++ b/libarchive/_libarchive_wrap.c @@ -3274,11 +3274,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) return pchar_descriptor ? SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); } else { -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromStringAndSize(carray, (int)(size)); -#else - return PyString_FromStringAndSize(carray, (int)(size)); -#endif +return PyUnicode_FromStringAndSize(carray, (int)(size)); } } else { return SWIG_Py_Void(); @@ -3342,7 +3338,7 @@ 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 = PyString_FromStringAndSize(NULL, len))) { + if (!(str = PyUnicode_FromStringAndSize(NULL, len))) { PyErr_SetString(PyExc_MemoryError, "could not allocate string."); return NULL; }