python-lzf
python-lzf copied to clipboard
Unexpected exit on python 3.7 and win10.
OS: Windows 10 Pro 64bit build 10.0.17134.648 Python: Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
My python exit without any error code when i input binary data to lzf.compress. Works fine on ubuntu 18.04.
Example code for generate the fault.
import lzf
from random import randint
input = bytes([randint(0, 255) for p in range(0, 512)])
print("compressing 512 bytes")
output = lzf.compress( input)
print("done compressing 512 bytes")
I am getting similar behavior. Were you able to find out anything about what caused the problem @mikaelsundin?
My python exit without any error code when i input binary data to lzf.compress.
The project uses the wrong preprocessor definitions to check for Windows. I am using this patch for the binaries at https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-lzf:
diff --git a/lzfP.h b/lzfP.h
index 7b7feda..e4926ef 100644
--- a/lzfP.h
+++ b/lzfP.h
@@ -141,7 +141,7 @@ using namespace std;
#endif
#ifndef LZF_USE_OFFSETS
-# if defined (WIN32)
+# if defined (_WIN32)
# define LZF_USE_OFFSETS defined(_M_X64)
# else
# if __cplusplus > 199711L
diff --git a/lzf_c.c b/lzf_c.c
index bc07084..9020a37 100644
--- a/lzf_c.c
+++ b/lzf_c.c
@@ -119,7 +119,7 @@ lzf_compress (const void *const in_data, unsigned int in_len,
* and fails to support both assumptions is windows 64 bit, we make a
* special workaround for it.
*/
-#if defined (WIN32) && defined (_M_X64)
+#if defined (_WIN32) && defined (_M_X64)
unsigned _int64 off; /* workaround for missing POSIX compliance */
#else
unsigned long off;
diff --git a/lzf_module.c b/lzf_module.c
index 7bc7b1a..8615d73 100644
--- a/lzf_module.c
+++ b/lzf_module.c
@@ -28,7 +28,7 @@ python_compress(PyObject *self, PyObject *args) {
return NULL;
if (pyoutlen == Py_None)
- outlen = inlen - 1;
+ outlen = ((inlen * 33) >> 5 ) + 1;
else if (PyInt_CheckExact(pyoutlen))
outlen = PyInt_AsLong(pyoutlen);
else if (PyLong_CheckExact(pyoutlen))
This fixed the problem for me, thanks @cgohlke!
Same issue here, any chance that the fix will be merged at some point?