diff --git a/libarchive/Makefile b/libarchive/Makefile index 5d7b8e6..ad967ee 100644 --- a/libarchive/Makefile +++ b/libarchive/Makefile @@ -1,13 +1,14 @@ -CFLAGS = -g +CFLAGS = -g INCLUDE = -I/usr/include -I. LIBS = -larchive -PYVER ?= 3.10 +PYVER ?= 3.9 all: __libarchive.so _libarchive_wrap.c: _libarchive.i - swig -python -shadow _libarchive.i + #swig -python -c++ -Wall -shadow _libarchive.i + swig -python -Wall -shadow _libarchive.i _libarchive_wrap.o: _libarchive_wrap.c ${CC} -c ${CFLAGS} -fPIC ${INCLUDE} $$(python${PYVER}-config --cflags) _libarchive_wrap.c diff --git a/libarchive/__init__.py b/libarchive/__init__.py index a6053f5..f387896 100644 --- a/libarchive/__init__.py +++ b/libarchive/__init__.py @@ -29,12 +29,13 @@ import sys import time import warnings -from ctypes import cdll, c_char_p +#from ctypes import cdll, c_char_p from libarchive import _libarchive from io import StringIO -PY3 = sys.version_info[0] == 3 +#PY3 = sys.version_info[0] == 3 +PY3 = True # Suggested block size for libarchive. Libarchive may adjust it. BLOCK_SIZE = 10240 diff --git a/libarchive/_libarchive.i b/libarchive/_libarchive.i index 5c2645c..ccf48f2 100644 --- a/libarchive/_libarchive.i +++ b/libarchive/_libarchive.i @@ -318,8 +318,8 @@ extern const char *archive_error_string(struct archive *); /* CONSTANTS */ -#define ARCHIVE_VERSION_NUMBER 3000001 -#define ARCHIVE_VERSION_STRING "libarchive 3.0.1b" +#define ARCHIVE_VERSION_NUMBER 3005003 +#define ARCHIVE_VERSION_STRING "libarchive 3.5.2" #define ARCHIVE_EOF 1 /* Found end of archive. */ #define ARCHIVE_OK 0 /* Operation was successful. */ #define ARCHIVE_RETRY (-10) /* Retry might succeed. */ diff --git a/libarchive/_libarchive_wrap.c b/libarchive/_libarchive_wrap.c index 4701b3e..def83ec 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_AsUTF8(x) +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(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, (void*)PyString_AS_STRING(str), len)) { + if (len != archive_read_data(archive, 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, (const void *)PyString_AS_STRING(str), len)) { + if (!archive_write_data(archive, PyString_AS_STRING(str), len)) { PyErr_SetString(PyExc_RuntimeError, "could not write requested data."); return NULL; } @@ -6545,8 +6545,8 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3000001))); - SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.0.1b")); + SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_NUMBER",SWIG_From_int((int)(3005003))); + SWIG_Python_SetConstant(d, "ARCHIVE_VERSION_STRING",SWIG_FromCharPtr("libarchive 3.5.2")); SWIG_Python_SetConstant(d, "ARCHIVE_EOF",SWIG_From_int((int)(1))); SWIG_Python_SetConstant(d, "ARCHIVE_OK",SWIG_From_int((int)(0))); SWIG_Python_SetConstant(d, "ARCHIVE_RETRY",SWIG_From_int((int)((-10)))); diff --git a/tests.py b/tests.py index fcba1d7..baec6dc 100644 --- a/tests.py +++ b/tests.py @@ -33,7 +33,8 @@ import io from libarchive import Archive, is_archive_name, is_archive from libarchive.zip import is_zipfile, ZipFile, ZipEntry -PY3 = sys.version_info[0] == 3 +#PY3 = sys.version_info[0] == 3 +PY3 = True TMPDIR = tempfile.mkdtemp(suffix='.python-libarchive') ZIPFILE = 'test.zip'