diff --git a/fix_build_dir_in_tests.patch b/fix_build_dir_in_tests.patch deleted file mode 100644 index 3aeb69a..0000000 --- a/fix_build_dir_in_tests.patch +++ /dev/null @@ -1,29 +0,0 @@ -From b47cba0a1ee062273569c076f96562770e641131 Mon Sep 17 00:00:00 2001 -From: SVN-Git Migration -Date: Thu, 8 Oct 2015 12:13:26 -0700 -Subject: fix_build_dir_in_tests - -Patch-Name: fix_build_dir_in_tests.patch ---- - test/__init__.py | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/test/__init__.py b/test/__init__.py -index 08a10a4..87bc6a9 100644 ---- a/test/__init__.py -+++ b/test/__init__.py -@@ -1,11 +1,12 @@ - import glob, os.path, sys -+from os import environ - - version = sys.version.split(" ")[0] - majorminor = version[0:3] - - # Add path to hiredis.so load path --path = glob.glob("build/lib*-%s/hiredis" % majorminor)[0] --sys.path.insert(0, path) -+path = glob.glob("build/lib*-%s/hiredis" % majorminor) -+sys.path.insert(0, environ.get('BUILDDIR', path and path[0])) - - from unittest import * - from . import reader diff --git a/hiredis1.patch b/hiredis1.patch new file mode 100644 index 0000000..f83365a --- /dev/null +++ b/hiredis1.patch @@ -0,0 +1,188 @@ +From 9084152f624e8e593b4e86ddf8bd13329fdfc043 Mon Sep 17 00:00:00 2001 +From: Illia Volochii +Date: Mon, 1 Mar 2021 20:48:33 +0200 +Subject: [PATCH] Bump hiredis from 0.13.3 to 1.0.0 + +--- + setup.py | 2 +- + src/reader.c | 64 +++++++++++++++++++++++++++++++++++++++++++------- + test/reader.py | 36 ++++++++++++++++++++++++++++ + vendor/hiredis | 2 +- + 4 files changed, 93 insertions(+), 11 deletions(-) + +Index: hiredis-py-1.1.0/src/reader.c +=================================================================== +--- hiredis-py-1.1.0.orig/src/reader.c ++++ hiredis-py-1.1.0/src/reader.c +@@ -69,8 +69,26 @@ static void *tryParentize(const redisRea + PyObject *parent; + if (task && task->parent) { + parent = (PyObject*)task->parent->obj; +- assert(PyList_CheckExact(parent)); +- PyList_SET_ITEM(parent, task->idx, obj); ++ switch (task->parent->type) { ++ case REDIS_REPLY_MAP: ++ if (task->idx % 2 == 0) { ++ /* Set a temporary item to save the object as a key. */ ++ PyDict_SetItem(parent, obj, Py_None); ++ } else { ++ /* Pop the temporary item and set proper key and value. */ ++ PyObject *last_item = PyObject_CallMethod(parent, "popitem", NULL); ++ PyObject *last_key = PyTuple_GetItem(last_item, 0); ++ PyDict_SetItem(parent, last_key, obj); ++ } ++ break; ++ case REDIS_REPLY_SET: ++ assert(PyAnySet_CheckExact(parent)); ++ PySet_Add(parent, obj); ++ break; ++ default: ++ assert(PyList_CheckExact(parent)); ++ PyList_SET_ITEM(parent, task->idx, obj); ++ } + } + return obj; + } +@@ -131,14 +149,28 @@ static void *createStringObject(const re + Py_INCREF(obj); + } + } else { ++ if (task->type == REDIS_REPLY_VERB) { ++ /* Skip 4 bytes of verbatim type header. */ ++ memmove(str, str+4, len); ++ len -= 4; ++ } + obj = createDecodedString(self, str, len); + } + return tryParentize(task, obj); + } + +-static void *createArrayObject(const redisReadTask *task, int elements) { ++static void *createArrayObject(const redisReadTask *task, size_t elements) { + PyObject *obj; +- obj = PyList_New(elements); ++ switch (task->type) { ++ case REDIS_REPLY_MAP: ++ obj = PyDict_New(); ++ break; ++ case REDIS_REPLY_SET: ++ obj = PySet_New(NULL); ++ break; ++ default: ++ obj = PyList_New(elements); ++ } + return tryParentize(task, obj); + } + +@@ -148,28 +180,42 @@ static void *createIntegerObject(const r + return tryParentize(task, obj); + } + ++static void *createDoubleObject(const redisReadTask *task, double value, char *str, size_t le) { ++ PyObject *obj; ++ obj = PyFloat_FromDouble(value); ++ return tryParentize(task, obj); ++} ++ + static void *createNilObject(const redisReadTask *task) { + PyObject *obj = Py_None; + Py_INCREF(obj); + return tryParentize(task, obj); + } + ++static void *createBoolObject(const redisReadTask *task, int bval) { ++ PyObject *obj; ++ obj = PyBool_FromLong((long)bval); ++ return tryParentize(task, obj); ++} ++ + static void freeObject(void *obj) { + Py_XDECREF(obj); + } + + redisReplyObjectFunctions hiredis_ObjectFunctions = { + createStringObject, // void *(*createString)(const redisReadTask*, char*, size_t); +- createArrayObject, // void *(*createArray)(const redisReadTask*, int); ++ createArrayObject, // void *(*createArray)(const redisReadTask*, size_t); + createIntegerObject, // void *(*createInteger)(const redisReadTask*, long long); ++ createDoubleObject, // void *(*createDoubleObject)(const redisReadTask*, double, char*, size_t); + createNilObject, // void *(*createNil)(const redisReadTask*); ++ createBoolObject, // void *(*createBoolObject)(const redisReadTask*, int); + freeObject // void (*freeObject)(void*); + }; + + static void Reader_dealloc(hiredis_ReaderObject *self) { + // we don't need to free self->encoding as the buffer is managed by Python + // https://docs.python.org/3/c-api/arg.html#strings-and-buffers +- redisReplyReaderFree(self->reader); ++ redisReaderFree(self->reader); + Py_XDECREF(self->protocolErrorClass); + Py_XDECREF(self->replyErrorClass); + +@@ -293,7 +339,7 @@ static PyObject *Reader_feed(hiredis_Rea + goto error; + } + +- redisReplyReaderFeed(self->reader, (char *)buf.buf + off, len); ++ redisReaderFeed(self->reader, (char *)buf.buf + off, len); + PyBuffer_Release(&buf); + Py_RETURN_NONE; + +@@ -312,8 +358,8 @@ static PyObject *Reader_gets(hiredis_Rea + return NULL; + } + +- if (redisReplyReaderGetReply(self->reader, (void**)&obj) == REDIS_ERR) { +- errstr = redisReplyReaderGetError(self->reader); ++ if (redisReaderGetReply(self->reader, (void**)&obj) == REDIS_ERR) { ++ errstr = redisReaderGetError(self->reader); + /* protocolErrorClass might be a callable. call it, then use it's type */ + err = createError(self->protocolErrorClass, errstr, strlen(errstr)); + if (err != NULL) { +Index: hiredis-py-1.1.0/test/reader.py +=================================================================== +--- hiredis-py-1.1.0.orig/test/reader.py ++++ hiredis-py-1.1.0/test/reader.py +@@ -118,6 +118,42 @@ class ReaderTest(TestCase): + self.reader.feed((":%d\r\n" % value).encode("ascii")) + self.assertEquals(value, self.reply()) + ++ def test_float(self): ++ value = -99.99 ++ self.reader.feed(b",%f\r\n" % value) ++ self.assertEqual(value, self.reply()) ++ ++ def test_boolean_true(self): ++ self.reader.feed(b"#t\r\n") ++ self.assertTrue(self.reply()) ++ ++ def test_boolean_false(self): ++ self.reader.feed(b"#f\r\n") ++ self.assertFalse(False, self.reply()) ++ ++ def test_none(self): ++ self.reader.feed(b"_\r\n") ++ self.assertIsNone(self.reply()) ++ ++ def test_set(self): ++ self.reader.feed(b"~3\r\n+tangerine\r\n_\r\n,10.5\r\n") ++ self.assertEqual({b"tangerine", None, 10.5}, self.reply()) ++ ++ def test_dict(self): ++ self.reader.feed(b"%2\r\n+radius\r\n,4.5\r\n+diameter\r\n:9\r\n") ++ self.assertEqual({b"radius": 4.5, b"diameter": 9}, self.reply()) ++ ++ def test_vector(self): ++ self.reader.feed(b">4\r\n+pubsub\r\n+message\r\n+channel\r\n+message\r\n") ++ self.assertEqual( ++ [b"pubsub", b"message", b"channel", b"message"], self.reply() ++ ) ++ ++ def test_verbatim_string(self): ++ value = b"text" ++ self.reader.feed(b"=8\r\ntxt:%s\r\n" % value) ++ self.assertEqual(value, self.reply()) ++ + def test_status_string(self): + self.reader.feed(b"+ok\r\n") + self.assertEquals(b"ok", self.reply()) diff --git a/python-hiredis.changes b/python-hiredis.changes index 66a4886..c37e639 100644 --- a/python-hiredis.changes +++ b/python-hiredis.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Feb 1 09:48:43 UTC 2021 - Markéta Machová + +- Update to 1.1.0 + * Allow "encoding" and "errors" attributes to be updated at runtime (see #96) +- Drop fix_build_dir_in_tests.patch +- Add hiredis1.patch to fix build with hiredis 1.0.0 + ------------------------------------------------------------------- Thu Jan 16 08:54:49 UTC 2020 - Tomáš Chvátal diff --git a/python-hiredis.spec b/python-hiredis.spec index 02ef538..335dc62 100644 --- a/python-hiredis.spec +++ b/python-hiredis.spec @@ -1,7 +1,7 @@ # # spec file for package python-hiredis # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,19 +18,19 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-hiredis -Version: 1.0.1 +Version: 1.1.0 Release: 0 Summary: Python wrapper for hiredis License: BSD-3-Clause URL: https://github.com/redis/hiredis-py Source: https://github.com/redis/hiredis-py/archive/v%{version}.tar.gz Patch0: 0001-Use-system-libhiredis.patch -Patch1: fix_build_dir_in_tests.patch Patch2: drop-vendor-sources.patch +Patch3: hiredis1.patch BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} BuildRequires: fdupes -BuildRequires: hiredis-devel >= 0.13.3 +BuildRequires: hiredis-devel >= 1.0.0 BuildRequires: python-rpm-macros %python_subpackages @@ -49,7 +49,9 @@ Python wrapper for hiredis C connector. %python_expand %fdupes %{buildroot}%{$python_sitearch} %check -%python_exec test.py +%python_exec setup.py build_ext --inplace +export PYTHONPATH=%{buildroot}%{$python_sitearch} +%python_exec test.py -v %files %{python_files} %license COPYING diff --git a/v1.0.1.tar.gz b/v1.0.1.tar.gz deleted file mode 100644 index 6400d27..0000000 --- a/v1.0.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2970b6123b071d8f2abf4f87f2cbeb6cfd698036b9a1b713c052361e3c2849c0 -size 14215 diff --git a/v1.1.0.tar.gz b/v1.1.0.tar.gz new file mode 100644 index 0000000..af715c6 --- /dev/null +++ b/v1.1.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1505a519bd704a806f4dead32610f8fc9390d1ac8051a29dae1b7146be65e611 +size 14471