From 78914b41d31d24a3b3f206bc7a101eef2cbf638a Mon Sep 17 00:00:00 2001 From: blakechi <56323787+blakechi@users.noreply.github.com> Date: Fri, 5 Nov 2021 01:13:58 -0500 Subject: [PATCH 1/2] fix typo in README.md - change typo in [line:125](https://github.com/RedisJSON/redisjson-py/blob/master/README.md?plain=1#L125) from `TestDecoder` to `CustomDecoder` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93424a8..d7d1dc0 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ a JSON string for example: return str(obj) return json.JSONEncoder.encode(self, obj) - class TestDecoder(JSONDecoder): + class CustomDecoder(JSONDecoder): "A custom decoder for the custom class" def decode(self, obj): d = json.JSONDecoder.decode(self, obj) From b6e5126d843257d3ebca5eeea28abc008df99a9d Mon Sep 17 00:00:00 2001 From: blakechi <56323787+blakechi@users.noreply.github.com> Date: Sun, 7 Nov 2021 14:17:56 -0600 Subject: [PATCH 2/2] detect whether to use `basestring` or `str` detect whether to use `basestring` or `str` depending on Python 2 or 3 --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d7d1dc0..839293d 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ The following shows how to use this for a custom class that's stored as a JSON string for example: ```python - + import sys from json import JSONEncoder, JSONDecoder from rejson import Client @@ -126,7 +126,9 @@ a JSON string for example: "A custom decoder for the custom class" def decode(self, obj): d = json.JSONDecoder.decode(self, obj) - if isinstance(d, basestring) and d.startswith('CustomClass:'): + + str_type = basestring if sys.version_info.major == 2 else str + if isinstance(d, str_type) and d.startswith('CustomClass:'): return CustomClass(d) return d