aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/simplejson/py3
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-03-03 10:13:17 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-03-03 10:26:24 +0300
commit447f0b8e571b5132a99a71b81ba1ee924f51435e (patch)
treedb7915224d68467dc99f69ac4d1ca952c82863fa /contrib/python/simplejson/py3
parentca1a5c96ea931ab5142b78ed1a207e764a009f6c (diff)
downloadydb-447f0b8e571b5132a99a71b81ba1ee924f51435e.tar.gz
Intermediate changes
commit_hash:e645500e80034e09b6e91446cb4262c113d3b5fe
Diffstat (limited to 'contrib/python/simplejson/py3')
-rw-r--r--contrib/python/simplejson/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/simplejson/py3/simplejson/__init__.py2
-rw-r--r--contrib/python/simplejson/py3/simplejson/_speedups.c34
-rw-r--r--contrib/python/simplejson/py3/simplejson/tests/test_dump.py6
-rw-r--r--contrib/python/simplejson/py3/ya.make2
5 files changed, 29 insertions, 17 deletions
diff --git a/contrib/python/simplejson/py3/.dist-info/METADATA b/contrib/python/simplejson/py3/.dist-info/METADATA
index 689e566f7f..bee5586b12 100644
--- a/contrib/python/simplejson/py3/.dist-info/METADATA
+++ b/contrib/python/simplejson/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: simplejson
-Version: 3.19.3
+Version: 3.20.1
Summary: Simple, fast, extensible JSON encoder/decoder for Python
Home-page: https://github.com/simplejson/simplejson
Author: Bob Ippolito
diff --git a/contrib/python/simplejson/py3/simplejson/__init__.py b/contrib/python/simplejson/py3/simplejson/__init__.py
index d3ff141d00..8bb46f15ed 100644
--- a/contrib/python/simplejson/py3/simplejson/__init__.py
+++ b/contrib/python/simplejson/py3/simplejson/__init__.py
@@ -118,7 +118,7 @@ Serializing multiple objects to JSON lines (newline-delimited JSON)::
"""
from __future__ import absolute_import
-__version__ = '3.19.3'
+__version__ = '3.20.1'
__all__ = [
'dump', 'dumps', 'load', 'loads',
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
diff --git a/contrib/python/simplejson/py3/simplejson/_speedups.c b/contrib/python/simplejson/py3/simplejson/_speedups.c
index bd56b4dc87..4133b9bc76 100644
--- a/contrib/python/simplejson/py3/simplejson/_speedups.c
+++ b/contrib/python/simplejson/py3/simplejson/_speedups.c
@@ -10,11 +10,13 @@
#define JSON_UNICHR Py_UCS4
#define JSON_InternFromString PyUnicode_InternFromString
#define PyString_GET_SIZE PyUnicode_GET_LENGTH
+#define JSON_StringCheck PyUnicode_Check
#define PY2_UNUSED
#define PY3_UNUSED UNUSED
#else /* PY_MAJOR_VERSION >= 3 */
#define PY2_UNUSED UNUSED
#define PY3_UNUSED
+#define JSON_StringCheck(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
#define PyBytes_Check PyString_Check
#define PyUnicode_READY(obj) 0
#define PyUnicode_KIND(obj) (sizeof(Py_UNICODE))
@@ -3034,25 +3036,29 @@ encoder_listencode_dict(PyEncoderObject *s, JSON_Accu *rval, PyObject *dct, Py_s
if (value == NULL)
goto bail;
- encoded = PyDict_GetItem(s->key_memo, key);
- if (encoded != NULL) {
- Py_INCREF(encoded);
- } else {
- kstr = encoder_stringify_key(s, key);
- if (kstr == NULL)
- goto bail;
- else if (kstr == Py_None) {
- /* skipkeys */
- Py_DECREF(item);
- Py_DECREF(kstr);
- continue;
- }
+ kstr = encoder_stringify_key(s, key);
+ if (kstr == NULL)
+ goto bail;
+ else if (kstr == Py_None) {
+ /* skipkeys */
+ Py_DECREF(item);
+ Py_DECREF(kstr);
+ continue;
}
if (idx) {
if (JSON_Accu_Accumulate(rval, s->item_separator))
goto bail;
}
- if (encoded == NULL) {
+ /*
+ * Only cache the encoding of string keys. False and True are
+ * indistinguishable from 0 and 1 in a dictionary lookup and there
+ * may be other quirks with user defined subclasses.
+ */
+ encoded = PyDict_GetItem(s->key_memo, kstr);
+ if (encoded != NULL) {
+ Py_INCREF(encoded);
+ Py_CLEAR(kstr);
+ } else {
encoded = encoder_encode_string(s, kstr);
Py_CLEAR(kstr);
if (encoded == NULL)
diff --git a/contrib/python/simplejson/py3/simplejson/tests/test_dump.py b/contrib/python/simplejson/py3/simplejson/tests/test_dump.py
index eff24c299c..5628489f26 100644
--- a/contrib/python/simplejson/py3/simplejson/tests/test_dump.py
+++ b/contrib/python/simplejson/py3/simplejson/tests/test_dump.py
@@ -73,6 +73,12 @@ class TestDump(TestCase):
{True: False, False: True}, sort_keys=True),
'{"false": true, "true": false}')
self.assertEqual(
+ # load first because the keys are not sorted
+ json.loads(json.dumps({'k1': {False: 5}, 'k2': {0: 5}})),
+ {'k1': {'false': 5}, 'k2': {'0': 5}},
+ )
+
+ self.assertEqual(
json.dumps(
{2: 3.0,
4.0: long_type(5),
diff --git a/contrib/python/simplejson/py3/ya.make b/contrib/python/simplejson/py3/ya.make
index 7537b289e7..1d192847a5 100644
--- a/contrib/python/simplejson/py3/ya.make
+++ b/contrib/python/simplejson/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(3.19.3)
+VERSION(3.20.1)
LICENSE(MIT)