diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000..4d39393 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,42 @@ +# Contributors + +Thanks go to these wonderful people ([emoji key](#emoji-key)): + + + + + +| Name | Contributions | +|------|---------------| +| [Markus F.X.J. Oberhumer](http://www.oberhumer.com/opensource/lzo/) | 💻 🚧 ⚠️ | +| [Joshua Boyd](https://github.com/jd-boyd) | 💻 🚧 ⚠️ | +| [glowinthedark](https://github.com/glowinthedark) | 💻 🚇 | +| [AT0myks](https://github.com/AT0myks) | 💻 🚇 | +| [Chris Angelico](https://github.com/Rosuav) | 💻 | +| [James Le Cuirot](https://github.com/chewi) | 💻 | +| [Vince Busam](https://github.com/vincecitizennet) | 💻 | +| [Eli Green](https://github.com/eli-green) | 💻 | +| [Antoine Martin](https://github.com/totaam) | 💻 | +| [Stuart Donnan](https://github.com/stuarth) | 💻 | +| [John Donners](https://github.com/jdonners) | 💻 | +| [mrTsjolder](https://github.com/mrTsjolder) | 💻 | +| [Sudipta Borah](https://github.com/sudiptaborah) | 💻 ⚠️ | +| [Xiaoqiang Wang](https://github.com/xiaoqiangwang) | 💻 | + + + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome! + +## Emoji Key + +This project uses the following emoji keys to indicate types of contributions: + +| Emoji | Type | +|-------|------| +| 💻 | Code | +| 🚧 | Maintenance | +| ⚠️ | Tests | +| 🚇 | Infrastructure | \ No newline at end of file diff --git a/README.md b/README.md index 4ac0ac7..3318d7c 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,18 @@ Copyright (c) 1996-2002 Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ - Copyright (c) 2011-2016 Joshua D. Boyd + Copyright (c) 2011-2026 Joshua D. Boyd (and other contributers) https://github.com/jd-boyd/python-lzo ``` -# What is LZO ? +# Maintainer Note + +I don't get paid to work on this. I don't use this in my work currently, and probably won't again. Maintainance is of the best effort sort. If someone things they can and want to do better, feel free to talk to me, since I'd be happy to hand it off to someone who can convince me they will be a better home. +-- jdboyd + +# What is LZO ? LZO is a portable lossless data compression library written in ANSI C. It offers pretty fast compression and *very* fast decompression. @@ -85,8 +90,15 @@ programs that ship with the LZO library. # Python 2 support statement -Python 2.7 is still supported but without being a priority. -Support will be dropped soon. +Python 2 support is removed. + +# Python 3.x support statement + +While we aren't going out of our way to drop support for older python 3.xs, we perform testing primarily on non-EOL Python versions. At the time of this writing, that means 3.10 and newer, although we haven't yet taken 3.9 off the test list. + +# Python 3.x known to no longer work + +This is a new section, and I'm not going to try to test every version right now, so I will say that 3.3 and older is known not to work, I guess 3.4 to 3.8 are currently a mystery. # Notes @@ -103,6 +115,10 @@ Python version that it can run tests for. 1. wheels (download from github actions) 1. Upload to PyPi (`twine upload dist/*`) +# Contribution + +Contributors will now be listed in CONTRIBUTERS.md. Just make a PR on github. + # Copyright The LZO and Python-LZO algorithms and implementations are @@ -111,7 +127,7 @@ Markus Franz Xaver Johannes Oberhumer The Python-LZO algorithms implementated post 2011 are Copyright (C) 2011, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, -2022, & 2023 +2022, 2023, 2026 Joshua D. Boyd and others as denoted in the git history. diff --git a/lzomodule.c b/lzomodule.c index ae5fa19..71fe338 100644 --- a/lzomodule.c +++ b/lzomodule.c @@ -45,26 +45,11 @@ #include #include -/* Python 2x3 compatible macros */ -#if PY_VERSION_HEX >= 0x03000000 -# define PyInt_FromLong PyLong_FromLong -# define PyString_FromString PyBytes_FromString -# define PyString_FromStringAndSize PyBytes_FromStringAndSize -# define PyString_AsString PyBytes_AsString -# define _PyString_Resize _PyBytes_Resize -#endif - /* Ensure we have updated versions */ -#if !defined(PY_VERSION_HEX) || (PY_VERSION_HEX < 0x010502f0) -# error "Need Python version 1.5.2 or greater" -#endif #if !defined(LZO_VERSION) || (LZO_VERSION < 0x1070) # error "Need LZO version 1.07 or greater" #endif - - - #undef UNUSED #define UNUSED(var) ((void)&var) @@ -113,11 +98,7 @@ compress(PyObject *dummy, PyObject *args, PyObject *kwds) /* init */ UNUSED(dummy); -#if PY_VERSION_HEX >= 0x03030000 if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii$s", argnames, &in, &len, &level, &header, &algorithm)) -#else - if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|iis", argnames, &in, &len, &level, &header, &algorithm)) -#endif return NULL; if (len < 0) return NULL; @@ -210,11 +191,7 @@ compress(PyObject *dummy, PyObject *args, PyObject *kwds) out_len = in_len + in_len / 16 + 64 + 3; /* alloc buffers */ -#if PY_MAJOR_VERSION >= 3 result_str = PyBytes_FromStringAndSize(NULL, 5 + out_len); -#else - result_str = PyString_FromStringAndSize(NULL, 5 + out_len); -#endif if (result_str == NULL) return PyErr_NoMemory(); if (level == 1) @@ -228,11 +205,7 @@ compress(PyObject *dummy, PyObject *args, PyObject *kwds) } /* compress */ -#if PY_MAJOR_VERSION >= 3 out = (lzo_bytep) PyBytes_AsString(result_str); -#else - out = (lzo_bytep) PyString_AsString(result_str); -#endif Py_BEGIN_ALLOW_THREADS outc = header ? out+5 : out; // leave space for header if needed @@ -270,11 +243,7 @@ compress(PyObject *dummy, PyObject *args, PyObject *kwds) /* return */ if (new_len != out_len) -#if PY_MAJOR_VERSION >= 3 _PyBytes_Resize(&result_str, header ? new_len + 5 : new_len); -#else - _PyString_Resize(&result_str, header ? new_len + 5 : new_len); -#endif return result_str; } @@ -313,11 +282,7 @@ decompress(PyObject *dummy, PyObject *args, PyObject *kwds) /* init */ UNUSED(dummy); -#if PY_VERSION_HEX >= 0x03030000 if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|ii$s", argnames, &in, &len, &header, &buflen, &algorithm)) -#else - if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#|iis", argnames, &in, &len, &header, &buflen, &algorithm)) -#endif return NULL; if (header) { if (len < 5 + 3 || in[0] < 0xf0 || in[0] > 0xf1) @@ -373,20 +338,12 @@ decompress(PyObject *dummy, PyObject *args, PyObject *kwds) } /* alloc buffers */ -#if PY_MAJOR_VERSION >= 3 result_str = PyBytes_FromStringAndSize(NULL, out_len); -#else - result_str = PyString_FromStringAndSize(NULL, out_len); -#endif if (result_str == NULL) return PyErr_NoMemory(); /* decompress */ -#if PY_MAJOR_VERSION >= 3 out = (lzo_bytep) PyBytes_AsString(result_str); -#else - out = (lzo_bytep) PyString_AsString(result_str); -#endif Py_BEGIN_ALLOW_THREADS new_len = out_len; @@ -401,7 +358,7 @@ decompress(PyObject *dummy, PyObject *args, PyObject *kwds) } if (!header && new_len != out_len) - _PyString_Resize(&result_str, new_len); + _PyBytes_Resize(&result_str, new_len); /* success */ return result_str; @@ -457,11 +414,7 @@ optimize(PyObject *dummy, PyObject *args) } /* alloc buffers */ -#if PY_MAJOR_VERSION >= 3 result_str = PyBytes_FromStringAndSize(in, len); -#else - result_str = PyString_FromStringAndSize(in, len); -#endif if (result_str == NULL) return PyErr_NoMemory(); out = (lzo_bytep) PyMem_Malloc(out_len > 0 ? out_len : 1); @@ -472,11 +425,7 @@ optimize(PyObject *dummy, PyObject *args) } /* optimize */ -#if PY_MAJOR_VERSION >= 3 in = (lzo_bytep) PyBytes_AsString(result_str); -#else - in = (lzo_bytep) PyString_AsString(result_str); -#endif Py_BEGIN_ALLOW_THREADS new_len = out_len; @@ -528,11 +477,7 @@ adler32(PyObject *dummy, PyObject *args) Py_END_ALLOW_THREADS } -#if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(val); -#else - return PyInt_FromLong(val); -#endif } @@ -559,11 +504,7 @@ crc32(PyObject *dummy, PyObject *args) return NULL; if (len > 0) val = lzo_crc32((lzo_uint32)val, (const lzo_bytep)buf, len); -#if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(val); -#else - return PyInt_FromLong(val); -#endif } @@ -597,7 +538,6 @@ static /* const */ char module_documentation[]= "optimize(string, ...) -- See help(lzo.optimize) for more options.\n" ; -#if PY_MAJOR_VERSION >= 3 static PyModuleDef module = { PyModuleDef_HEAD_INIT, "lzo", /* name */ @@ -609,77 +549,41 @@ static PyModuleDef module = { NULL, /* clear */ NULL, /* free */ }; -#endif #ifdef _MSC_VER _declspec(dllexport) #endif -#if PY_MAJOR_VERSION >= 3 PyMODINIT_FUNC PyInit_lzo(void) -#else -void initlzo(void) -#endif { PyObject *m, *d, *v; if (lzo_init() != LZO_E_OK) -#if PY_MAJOR_VERSION >= 3 return NULL; -#else - return; -#endif -#if PY_MAJOR_VERSION >= 3 m = PyModule_Create(&module); -#else - m = Py_InitModule4("lzo", methods, module_documentation, - NULL, PYTHON_API_VERSION); -#endif d = PyModule_GetDict(m); LzoError = PyErr_NewException("lzo.error", NULL, NULL); PyDict_SetItemString(d, "error", LzoError); -#if PY_MAJOR_VERSION >= 3 - v = PyBytes_FromString("Markus F.X.J. Oberhumer "); -#else - v = PyString_FromString("Markus F.X.J. Oberhumer "); -#endif + v = PyUnicode_FromString("Markus F.X.J. Oberhumer "); PyDict_SetItemString(d, "__author__", v); Py_DECREF(v); -#if PY_MAJOR_VERSION >= 3 - v = PyBytes_FromString(MODULE_VERSION); -#else - v = PyString_FromString(MODULE_VERSION); -#endif + v = PyUnicode_FromString(MODULE_VERSION); PyDict_SetItemString(d, "__version__", v); Py_DECREF(v); -#if PY_MAJOR_VERSION >= 3 v = PyLong_FromLong((long)lzo_version()); -#else - v = PyInt_FromLong((long)lzo_version()); -#endif PyDict_SetItemString(d, "LZO_VERSION", v); Py_DECREF(v); -#if PY_MAJOR_VERSION >= 3 - v = PyBytes_FromString(lzo_version_string()); -#else - v = PyString_FromString(lzo_version_string()); -#endif + v = PyUnicode_FromString(lzo_version_string()); PyDict_SetItemString(d, "LZO_VERSION_STRING", v); Py_DECREF(v); -#if PY_MAJOR_VERSION >= 3 - v = PyBytes_FromString(lzo_version_date()); -#else - v = PyString_FromString(lzo_version_date()); -#endif + v = PyUnicode_FromString(lzo_version_date()); PyDict_SetItemString(d, "LZO_VERSION_DATE", v); Py_DECREF(v); -#if PY_MAJOR_VERSION >= 3 return m; -#endif } diff --git a/setup.py b/setup.py index 14f57eb..52dc465 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # vi:ts=4:et -from __future__ import print_function - import os import subprocess import sys diff --git a/tests/test_lzo.py b/tests/test_lzo.py index 982a8b9..fea9e76 100644 --- a/tests/test_lzo.py +++ b/tests/test_lzo.py @@ -30,7 +30,6 @@ ## ##---------------------------------------------------------------------------## -from __future__ import print_function import inspect import pytest import sys, string @@ -112,7 +111,7 @@ def test_version(): else: import pkg_resources pkg_version = pkg_resources.require("python-lzo")[0].version - mod_version = lzo.__version__.decode('utf-8') + mod_version = lzo.__version__ assert pkg_version == mod_version, \ "%r != %r" %(pkg_version, mod_version)