diff options
Diffstat (limited to 'dev-python/ujson')
-rw-r--r-- | dev-python/ujson/Manifest | 14 | ||||
-rw-r--r-- | dev-python/ujson/files/ujson-1.33-test-py3.patch | 38 | ||||
-rw-r--r-- | dev-python/ujson/files/ujson-1.35-fix-for-overflowing-long.patch | 84 | ||||
-rw-r--r-- | dev-python/ujson/files/ujson-1.35-fix-ordering-of-orderdict.patch | 122 | ||||
-rw-r--r-- | dev-python/ujson/files/ujson-1.35-sort_keys-segfault.patch | 73 | ||||
-rw-r--r-- | dev-python/ujson/files/ujson-1.35-standard-handling-of-none.patch | 77 | ||||
-rw-r--r-- | dev-python/ujson/files/ujson-1.35-test-depricationwarning.patch | 11 | ||||
-rw-r--r-- | dev-python/ujson/files/ujson-1.35-use-static-where-possible.patch | 591 | ||||
-rw-r--r-- | dev-python/ujson/metadata.xml | 15 | ||||
-rw-r--r-- | dev-python/ujson/ujson-1.33.ebuild | 44 | ||||
-rw-r--r-- | dev-python/ujson/ujson-1.35.ebuild | 33 |
11 files changed, 1102 insertions, 0 deletions
diff --git a/dev-python/ujson/Manifest b/dev-python/ujson/Manifest new file mode 100644 index 000000000000..c7872978c03e --- /dev/null +++ b/dev-python/ujson/Manifest @@ -0,0 +1,14 @@ +AUX ujson-1.33-test-py3.patch 1256 SHA256 814dcdb74e48ea3662adfc6145a503678f17128a5f585b0279d74906f6fc3257 SHA512 f05909d1ecc51123da75de817ce52d7d24e7510ebd353c11b483f8f4bad177d7031ed84336e60647425ec24f0dddeec1966511971bdaee4abbc10d2ac11cb32b WHIRLPOOL d0b93db66651795cf4cfaad8ece277f642a5e6a66bdf1286990ec58dfb9d177ced46484c856d1518421101b39ea417515041adcdc096a4ee19ec1cd4ca5c633c +AUX ujson-1.35-fix-for-overflowing-long.patch 2630 SHA256 d3356310af1f45929fc55434b0310a4f2507c00cd531937b6c7595d5cd2db61e SHA512 1006a559fba644985663acbf3a94b8485511a0b137e96191c15f791ef1b84824dfd3d26ffb7de3bcecd011ab94e04b46e2ffbdf90766cb95c11be9c508cfc847 WHIRLPOOL 8209dac0a7501fb0e221802fdc492b6c452bbc9cd611db615de7772e656f0dd5a21836cd10299d8aec809fc7c0d5704a332600fb60cd733a62edf9f77fd27e5e +AUX ujson-1.35-fix-ordering-of-orderdict.patch 4046 SHA256 9b0e72400165c547c64a8c1365d2df4f09d8632064e76d86dfcb1db7300a5107 SHA512 e3c392a4298f65154549f077c55da7b78d6e9085a217b3ef574ccec4d9f0466f5d0901c039afb1fb44b1e26042881abc5007eb045a3594ee365c09f46443d134 WHIRLPOOL 917260e5e2f6cbf4daae791b5c736e0f291d3e46b37eab2301da6f728da175929265497573688a8b1e72028edd2c2a8e4536b130e95cc3cbf15dac6e54de12b9 +AUX ujson-1.35-sort_keys-segfault.patch 2360 SHA256 0f921562c913a6ad4c8e8a4202559a39aff77bd1723d26e055cefbcd138cf6bf SHA512 aac5b264187be10cbfb2d128f1a415fd0d841a728b7c1975232e5fe37fc042b19aae084e9c807eb5c23b1fe8306565bb2867543c08d88c2abcf474401644f114 WHIRLPOOL 8d9056bf7260b94c1da1bcea789509aa4c2727b24baa76fe167a34c3db6409292f7ef6d5f2a453eff8cd91a83885f74d7b59d3c07477b9dc2172001fcefd1881 +AUX ujson-1.35-standard-handling-of-none.patch 2563 SHA256 39ffdab0976922409c4db4a584815e4e134dd0e989df49098f8e010fd66997e5 SHA512 3d3b7a3dc3d055c4c3cc94acdced6d5b154bfe23ff371230924f5ac7ea982997b2d404dc643c53e606c76b41a5d8c41d506d3f5d3adcc6cd61633f7dbaf3e30e WHIRLPOOL 9eceb0feaa74a66e0d5fa561240df155187f4a87e86d0e4632b8bb498a09a3d72c3fe116e28b55e30ab5a7fa359890ed9d40fc10fe8f827fe51919d83e25ad2f +AUX ujson-1.35-test-depricationwarning.patch 369 SHA256 a6a35fff98dfa565cc1821d4392e7b8f88f912929bf722de483ad011658e2183 SHA512 71fc8012f1701a35def3d7533d8d8d4133550dd57bd22b11e1dcd2806d25e185678f047cc1fe61a35132ed1d546d1411d452bb0e7af66aefe9b53a99b5ef3c66 WHIRLPOOL c4fdca550412b82bad3dbaf7e46f29dcfb06a0456be7e9b1f30435cbb590738bb4d5ca03e8ff9b712b1ee6b991bb267b8c2090a292f5e5a3c13d4293ec173668 +AUX ujson-1.35-use-static-where-possible.patch 19904 SHA256 0bf573eddddacb93d1baf0dc29351d7617729b9732107031d4b63eac3a5187b5 SHA512 fe96f88cde477bfdc63ad5cf360ab6c63e2cf00c192a8d70d80340b7e39820ca53554a775c8f32b7ca43259e9f299fe38ebaf4aa64ef12c035bf23085f5b5789 WHIRLPOOL b1df3dfb8d687153da3b1da30cece2ad006a04255c90364126ccc5f87182e3944598b7166d554a730170f5c98bde6db931000fbf5226aa446e6b076dbc239a5f +DIST ujson-1.33.zip 197034 SHA256 68cf825f227c82e1ac61e423cfcad923ff734c27b5bdd7174495d162c42c602b SHA512 0f1f66212fbf94c03e048ba64c3bd817c50443d1a29b87f6a3a38f697a050f38821be4ba36a3b17a96930c69ee92973ac31bdd41851dea071af14cd4bbaf8480 WHIRLPOOL d3080fcf3e979b43deb8fe099427a8311c55e7e54105626bf12b3b6fe9e8567f70501884bd24b7a26d53ddfcd98f535de4aa708801106aa4a1b76e543217835c +DIST ujson-1.35.tar.gz 192027 SHA256 f66073e5506e91d204ab0c614a148d5aa938bdbf104751be66f8ad7a222f5f86 SHA512 931d8f574fc4920c9ded48369774666060e951f40982606ce9f1d9de3420004042af7d797075a54d92a2b25c4f313572a5e1a30f3bc8ce387ef8f3881193eee7 WHIRLPOOL aff7a034304366e95ec51164de78afbee8daa496022abdae1b9928ea90928758e675027f2202ca77790788a3057c978d9ba9348684bc087843aa2e16932a1144 +EBUILD ujson-1.33.ebuild 1144 SHA256 459fb5dd3383bfaa462388f541157626e130ac26219d00c7d3920cfe7a075853 SHA512 c36504fe05d23c5b17278fbf0056e7aaa07ef66cd589693e81d1df0c83af3ad5b142fed7b2e15ec33853b8046992354a54adebd94a1443ee6503ecd2e6263eb9 WHIRLPOOL 87e543a432cc60069cb9d18fac1498b3261e332320a08b4cdac119e0437213a0ffbbf5a20e1448de9b371a1a7f1c11ae7405587dbd72323f68335c4800ae9be5 +EBUILD ujson-1.35.ebuild 847 SHA256 f01dcf550f22e0d91829543ca38eac05662e8f03e91dd97e60cadb9559f42f6c SHA512 79109e0a3085a5e74deb1cb919015b616c1c724a314e5f7d00b217bec1f01635f63cc0c032fcc2bc8787db29f98d86d098d6bc40d82a3468f75e02e2744ea4b6 WHIRLPOOL 5cb72b3ecb77996d4ccbe1e82338b573aa3b083ca07a0372129a22d4ef8f1529caef40017c613651c64120f3e5c6d6174f11f74855720c0c607f653c9745a0d3 +MISC ChangeLog 3016 SHA256 ce120b6960429fa1d1cbad2e549090609c39a0906553c61e3058165fe4aa11d1 SHA512 79b7ebf14fafb1c3c1ae621c81365e63cec58ce42a512bfd2160f068488e4b9b4825266a971bc34da987e80262d6bb7f59cfd9695e05aace000cc65ac71f3a03 WHIRLPOOL c0aba94e49ebfe4998c9cbd92937ac866df4c96d09fb5d8a2cf00599d72e7e597532388feeb4d78c5e9bf0902caf4b28374179b5ff8f93bc59aa18ad25306982 +MISC ChangeLog-2015 1542 SHA256 51eb298d16935530069767c3b8c85d625a67af6778ce6df9b39adbe2dca772b5 SHA512 41be15b522e08f8b4ca9a1e68d05b508384f1e695bf9134ec08556f97913ed4f59ab283d4ec392dab0ba6e8acb0cdc28e8a5be60407ec09f1301ad094793b8ce WHIRLPOOL 860ce016743ccc04f10e05f835a99e46bea8034641ab11315c6cdc2997151e5b88e5040bad79244e9741acb17bec404dfd437b7aa6cff87444b541338fca34e7 +MISC metadata.xml 432 SHA256 eaf4792579c57ddb0e74453ddd26cb6c04f8356f86eceb29ee0c860031c4c5e7 SHA512 485e866809b2704a344436f956dd242b8720ecf46daf53a7a64fcf8a5edd3b3915faf59d48da4224b361ba35f7ab8c346e16b0a037cf8846d663d175486bed8f WHIRLPOOL f4682217489bd28e6a14bb53ec89022daa4bbbb005861fc6436d4771902d80965a2ad8ffb699b12db55439652306f3b978d34fbe16f3cdec96dc3837a32335ef diff --git a/dev-python/ujson/files/ujson-1.33-test-py3.patch b/dev-python/ujson/files/ujson-1.33-test-py3.patch new file mode 100644 index 000000000000..e497f396792c --- /dev/null +++ b/dev-python/ujson/files/ujson-1.33-test-py3.patch @@ -0,0 +1,38 @@ + tests/tests.py | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/tests/tests.py b/tests/tests.py +index d210bc6..71f8074 100644 +--- a/tests/tests.py ++++ b/tests/tests.py +@@ -11,6 +11,7 @@ try: + except ImportError: + import simplejson as json + import math ++import nose + import platform + import sys + import time +@@ -24,9 +25,10 @@ from functools import partial + + PY3 = (sys.version_info[0] >= 3) + +-def _python_ver(skip_major, skip_minor=None): ++def _skip_if_python_ver(skip_major, skip_minor=None): + major, minor = sys.version_info[:2] +- return major == skip_major and (skip_minor is None or minor == skip_minor) ++ if major == skip_major and (skip_minor is None or minor == skip_minor): ++ raise nose.SkipTest + + json_unicode = (json.dumps if sys.version_info[0] >= 3 + else partial(json.dumps, encoding="utf-8")) +@@ -579,8 +581,8 @@ class UltraJSONTests(TestCase): + input = "-31337" + self.assertEquals (-31337, ujson.decode(input)) + +- #@unittest.skipIf(_python_ver(3), "No exception in Python 3") + def test_encodeUnicode4BytesUTF8Fail(self): ++ _skip_if_python_ver(3) + input = "\xfd\xbf\xbf\xbf\xbf\xbf" + try: + enc = ujson.encode(input) diff --git a/dev-python/ujson/files/ujson-1.35-fix-for-overflowing-long.patch b/dev-python/ujson/files/ujson-1.35-fix-for-overflowing-long.patch new file mode 100644 index 000000000000..98659ce1722b --- /dev/null +++ b/dev-python/ujson/files/ujson-1.35-fix-for-overflowing-long.patch @@ -0,0 +1,84 @@ +commit 409c6d4006fdea27e746ea397124f98c92a41a92 +Author: Joakim Hamren <joakim.hamren@gmail.com> +Date: Sat Feb 4 04:21:05 2017 +0100 + + Fix for overflowing long causing invalid json + + This was caused by checking for "__json__" using PyObject_HasAttrString + which clears the error set by a previous long overflow. Thus this was dependent + on the order of processing of dict items, which explains why it was + seemingly random as the dict items are likely ordered by a hash of + the key. + + This fixes GH224 and GH240. + +diff --git a/python/objToJSON.c b/python/objToJSON.c +index 8133fb5..adea2f6 100644 +--- a/python/objToJSON.c ++++ b/python/objToJSON.c +@@ -226,6 +226,21 @@ static void *PyDateToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size + return NULL; + } + ++static int PyHasAttrStringPreserveErr(PyObject *obj, const char *attr) ++{ ++ int res; ++ PyObject *excType = NULL, *excValue, *excTraceback; ++ ++ if (!PyErr_Occurred()) ++ return PyObject_HasAttrString(obj, "__json__"); ++ ++ PyErr_Fetch(&excType, &excValue, &excTraceback); ++ res = PyObject_HasAttrString(obj, "__json__"); ++ PyErr_Restore(excType, excValue, excTraceback); ++ ++ return res; ++} ++ + static int Tuple_iterNext(JSOBJ obj, JSONTypeContext *tc) + { + PyObject *item; +@@ -471,21 +486,21 @@ static int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) + GET_TC(tc)->itemName = PyUnicode_AsUTF8String (GET_TC(tc)->itemName); + } + else +- if (!PyString_Check(GET_TC(tc)->itemName)) +- { +- GET_TC(tc)->itemName = PyObject_Str(GET_TC(tc)->itemName); ++ if (!PyString_Check(GET_TC(tc)->itemName)) ++ { ++ GET_TC(tc)->itemName = PyObject_Str(GET_TC(tc)->itemName); + #if PY_MAJOR_VERSION >= 3 +- itemNameTmp = GET_TC(tc)->itemName; +- GET_TC(tc)->itemName = PyUnicode_AsUTF8String (GET_TC(tc)->itemName); +- Py_DECREF(itemNameTmp); ++ itemNameTmp = GET_TC(tc)->itemName; ++ GET_TC(tc)->itemName = PyUnicode_AsUTF8String (GET_TC(tc)->itemName); ++ Py_DECREF(itemNameTmp); + #endif +- } +- else +- { +- Py_INCREF(GET_TC(tc)->itemName); +- } +- PRINTMARK(); +- return 1; ++ } ++ else ++ { ++ Py_INCREF(GET_TC(tc)->itemName); ++ } ++ PRINTMARK(); ++ return 1; + } + + static void Dict_iterEnd(JSOBJ obj, JSONTypeContext *tc) +@@ -728,7 +743,7 @@ static void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObject + return; + } + else +- if (PyString_Check(obj) && !PyObject_HasAttrString(obj, "__json__")) ++ if (PyString_Check(obj) && !PyHasAttrStringPreserveErr(obj, "__json__")) + { + PRINTMARK(); + pc->PyTypeToJSON = PyStringToUTF8; tc->type = JT_UTF8; diff --git a/dev-python/ujson/files/ujson-1.35-fix-ordering-of-orderdict.patch b/dev-python/ujson/files/ujson-1.35-fix-ordering-of-orderdict.patch new file mode 100644 index 000000000000..37270d41e3b1 --- /dev/null +++ b/dev-python/ujson/files/ujson-1.35-fix-ordering-of-orderdict.patch @@ -0,0 +1,122 @@ +commit c9f8318bd823ae9d44797b6b881a2b3e22cdbade +Author: Joakim Hamren <joakim.hamren@gmail.com> +Date: Tue Feb 7 02:02:38 2017 +0100 + + Fix for incorrect order when using OrderedDict + +diff --git a/python/objToJSON.c b/python/objToJSON.c +index abe6588..9e6a390 100644 +--- a/python/objToJSON.c ++++ b/python/objToJSON.c +@@ -253,8 +253,13 @@ static int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) + GET_TC(tc)->itemName = NULL; + } + ++ if (!(GET_TC(tc)->itemName = PyIter_Next(GET_TC(tc)->iterator))) ++ { ++ PRINTMARK(); ++ return 0; ++ } + +- if (!PyDict_Next ( (PyObject *)GET_TC(tc)->dictObj, &GET_TC(tc)->index, &GET_TC(tc)->itemName, &GET_TC(tc)->itemValue)) ++ if (!(GET_TC(tc)->itemValue = PyObject_GetItem(GET_TC(tc)->dictObj, GET_TC(tc)->itemName))) + { + PRINTMARK(); + return 0; +@@ -295,6 +300,7 @@ static void Dict_iterEnd(JSOBJ obj, JSONTypeContext *tc) + Py_DECREF(GET_TC(tc)->itemName); + GET_TC(tc)->itemName = NULL; + } ++ Py_CLEAR(GET_TC(tc)->iterator); + Py_DECREF(GET_TC(tc)->dictObj); + PRINTMARK(); + } +@@ -425,20 +431,23 @@ static char *SortedDict_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outL + + static void SetupDictIter(PyObject *dictObj, TypeContext *pc, JSONObjectEncoder *enc) + { +- if (enc->sortKeys) { ++ pc->dictObj = dictObj; ++ if (enc->sortKeys) ++ { + pc->iterEnd = SortedDict_iterEnd; + pc->iterNext = SortedDict_iterNext; + pc->iterGetValue = SortedDict_iterGetValue; + pc->iterGetName = SortedDict_iterGetName; ++ pc->index = 0; + } +- else { ++ else ++ { + pc->iterEnd = Dict_iterEnd; + pc->iterNext = Dict_iterNext; + pc->iterGetValue = Dict_iterGetValue; + pc->iterGetName = Dict_iterGetName; ++ pc->iterator = PyObject_GetIter(dictObj); + } +- pc->dictObj = dictObj; +- pc->index = 0; + } + + static void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObjectEncoder *enc) +@@ -446,7 +455,8 @@ static void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObject + PyObject *obj, *objRepr, *exc; + TypeContext *pc; + PRINTMARK(); +- if (!_obj) { ++ if (!_obj) ++ { + tc->type = JT_INVALID; + return; + } +diff --git a/tests/tests.py b/tests/tests.py +index cd928e6..b7e46af 100644 +--- a/tests/tests.py ++++ b/tests/tests.py +@@ -10,6 +10,8 @@ import json + import math + import time + import pytz ++from collections import OrderedDict ++ + if six.PY2: + import unittest2 as unittest + else: +@@ -383,6 +385,10 @@ class UltraJSONTests(unittest.TestCase): + input = -float('inf') + self.assertRaises(OverflowError, ujson.encode, input) + ++ def test_encodeOrderedDict(self): ++ input = OrderedDict([(1, 1), (0, 0), (8, 8), (2, 2)]) ++ self.assertEqual('{"1":1,"0":0,"8":8,"2":2}', ujson.encode(input)) ++ + def test_decodeJibberish(self): + input = "fdsa sda v9sa fdsa" + self.assertRaises(ValueError, ujson.decode, input) +@@ -668,7 +674,7 @@ class UltraJSONTests(unittest.TestCase): + d = {u'key': JSONTest()} + output = ujson.encode(d) + dec = ujson.decode(output) +- self.assertEquals(dec, {u'key': output_text}) ++ self.assertEqual(dec, {u'key': output_text}) + + def test_object_with_json_unicode(self): + # If __json__ returns a string, then that string +@@ -681,7 +687,7 @@ class UltraJSONTests(unittest.TestCase): + d = {u'key': JSONTest()} + output = ujson.encode(d) + dec = ujson.decode(output) +- self.assertEquals(dec, {u'key': output_text}) ++ self.assertEqual(dec, {u'key': output_text}) + + def test_object_with_complex_json(self): + # If __json__ returns a string, then that string +@@ -694,7 +700,7 @@ class UltraJSONTests(unittest.TestCase): + d = {u'key': JSONTest()} + output = ujson.encode(d) + dec = ujson.decode(output) +- self.assertEquals(dec, {u'key': obj}) ++ self.assertEqual(dec, {u'key': obj}) + + def test_object_with_json_type_error(self): + # __json__ must return a string, otherwise it should raise an error. diff --git a/dev-python/ujson/files/ujson-1.35-sort_keys-segfault.patch b/dev-python/ujson/files/ujson-1.35-sort_keys-segfault.patch new file mode 100644 index 000000000000..7239bca3e238 --- /dev/null +++ b/dev-python/ujson/files/ujson-1.35-sort_keys-segfault.patch @@ -0,0 +1,73 @@ +commit 870ee48fe109c289033cd0b7543b6f5ea4e6f128 +Author: Joakim Hamren <joakim.hamren@gmail.com> +Date: Sat Feb 4 01:07:52 2017 +0100 + + Fixes for sort_keys bug and a typo. + + - Fixed segfault when using sort_keys=True on dict with unorderable keys (GH247) + + - Fixed refcount becoming negative when using sort_keys=True (GH243) + + - Fixed compile error when defining JSON_NO_EXTRA_WHITESPACE + caused by a wrongly named variable. (GH245) + +diff --git a/lib/ultrajsonenc.c b/lib/ultrajsonenc.c +index cb10024..1bfa8f4 100644 +--- a/lib/ultrajsonenc.c ++++ b/lib/ultrajsonenc.c +@@ -717,7 +717,7 @@ static void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t c + { + const char *value; + char *objName; +- int count; ++ int count, res; + JSOBJ iterObj; + size_t szlen; + JSONTypeContext tc; +@@ -796,7 +796,7 @@ static void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t c + { + Buffer_AppendCharUnchecked (enc, ','); + #ifndef JSON_NO_EXTRA_WHITESPACE +- Buffer_AppendCharUnchecked (buffer, ' '); ++ Buffer_AppendCharUnchecked (enc, ' '); + #endif + Buffer_AppendIndentNewlineUnchecked (enc); + } +@@ -823,8 +823,16 @@ static void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t c + Buffer_AppendCharUnchecked (enc, '{'); + Buffer_AppendIndentNewlineUnchecked (enc); + +- while (enc->iterNext(obj, &tc)) ++ while ((res = enc->iterNext(obj, &tc))) + { ++ if(res < 0) ++ { ++ enc->iterEnd(obj, &tc); ++ enc->endTypeContext(obj, &tc); ++ enc->level--; ++ return; ++ } ++ + if (count > 0) + { + Buffer_AppendCharUnchecked (enc, ','); +diff --git a/python/objToJSON.c b/python/objToJSON.c +index 1960d40..8133fb5 100644 +--- a/python/objToJSON.c ++++ b/python/objToJSON.c +@@ -537,6 +537,7 @@ static int SortedDict_iterNext(JSOBJ obj, JSONTypeContext *tc) + // Sort the list. + if (PyList_Sort(items) < 0) + { ++ PyErr_SetString(PyExc_ValueError, "unorderable keys"); + goto error; + } + +@@ -607,7 +608,6 @@ static void SortedDict_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + GET_TC(tc)->itemName = NULL; + GET_TC(tc)->itemValue = NULL; +- Py_DECREF(GET_TC(tc)->newObj); + Py_DECREF(GET_TC(tc)->dictObj); + PRINTMARK(); + } diff --git a/dev-python/ujson/files/ujson-1.35-standard-handling-of-none.patch b/dev-python/ujson/files/ujson-1.35-standard-handling-of-none.patch new file mode 100644 index 000000000000..e2b7b9103f48 --- /dev/null +++ b/dev-python/ujson/files/ujson-1.35-standard-handling-of-none.patch @@ -0,0 +1,77 @@ +commit ac4637fbc4e72bd59f221d9bba19127820d21023 +Author: Joakim Hamren <joakim.hamren@gmail.com> +Date: Sat Feb 4 16:36:14 2017 +0100 + + Following std json handling of None dict key + + Previously a None dict item key would be outputted in JSON as "None". + To better align with the standard json module this was changed to output + "null". There's no proper representation of null object keys in JSON so + this is implementation specific but it seems more natural to follow + suit when it can be done without a significant performance hit. + + Added and used branch prediction macros (LIKELY/UNLIKELY) as well. + +diff --git a/lib/ultrajson.h b/lib/ultrajson.h +index 6c1dbc1..ca82a29 100644 +--- a/lib/ultrajson.h ++++ b/lib/ultrajson.h +@@ -117,6 +117,14 @@ typedef uint32_t JSUINT32; + + #define INLINE_PREFIX inline + ++#ifdef __GNUC__ ++#define LIKELY(x) __builtin_expect(!!(x), 1) ++#define UNLIKELY(x) __builtin_expect(!!(x), 0) ++#else ++#define LIKELY(x) (x) ++#define UNLIKELY(x) (x) ++#endif ++ + typedef uint8_t JSUINT8; + typedef uint16_t JSUTF16; + typedef uint32_t JSUTF32; +diff --git a/python/objToJSON.c b/python/objToJSON.c +index adea2f6..41d4289 100644 +--- a/python/objToJSON.c ++++ b/python/objToJSON.c +@@ -488,6 +488,12 @@ static int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) + else + if (!PyString_Check(GET_TC(tc)->itemName)) + { ++ if (UNLIKELY(GET_TC(tc)->itemName == Py_None)) ++ { ++ GET_TC(tc)->itemName = PyString_FromString("null"); ++ return 1; ++ } ++ + GET_TC(tc)->itemName = PyObject_Str(GET_TC(tc)->itemName); + #if PY_MAJOR_VERSION >= 3 + itemNameTmp = GET_TC(tc)->itemName; +@@ -743,7 +749,7 @@ static void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObject + return; + } + else +- if (PyString_Check(obj) && !PyHasAttrStringPreserveErr(obj, "__json__")) ++ if (PyString_Check(obj) && LIKELY(!PyHasAttrStringPreserveErr(obj, "__json__"))) + { + PRINTMARK(); + pc->PyTypeToJSON = PyStringToUTF8; tc->type = JT_UTF8; +@@ -837,7 +843,7 @@ ISITERABLE: + } + */ + +- if (PyObject_HasAttrString(obj, "toDict")) ++ if (UNLIKELY(PyObject_HasAttrString(obj, "toDict"))) + { + PyObject* toDictFunc = PyObject_GetAttrString(obj, "toDict"); + PyObject* tuple = PyTuple_New(0); +@@ -863,7 +869,7 @@ ISITERABLE: + return; + } + else +- if (PyObject_HasAttrString(obj, "__json__")) ++ if (UNLIKELY(PyObject_HasAttrString(obj, "__json__"))) + { + PyObject* toJSONFunc = PyObject_GetAttrString(obj, "__json__"); + PyObject* tuple = PyTuple_New(0); diff --git a/dev-python/ujson/files/ujson-1.35-test-depricationwarning.patch b/dev-python/ujson/files/ujson-1.35-test-depricationwarning.patch new file mode 100644 index 000000000000..6ce987581c4f --- /dev/null +++ b/dev-python/ujson/files/ujson-1.35-test-depricationwarning.patch @@ -0,0 +1,11 @@ +--- ujson-1.35.orig/tests/tests.py 2017-04-14 18:14:36.298345782 -0700 ++++ ujson-1.35/tests/tests.py 2017-04-14 18:14:47.899947795 -0700 +@@ -702,7 +702,7 @@ + + output = ujson.encode(ObjectTest()) + dec = ujson.decode(output) +- self.assertEquals(dec, {}) ++ self.assertEqual(dec, {}) + + def test_toDict(self): + d = {"key": 31337} diff --git a/dev-python/ujson/files/ujson-1.35-use-static-where-possible.patch b/dev-python/ujson/files/ujson-1.35-use-static-where-possible.patch new file mode 100644 index 000000000000..7ce5d44e0e7a --- /dev/null +++ b/dev-python/ujson/files/ujson-1.35-use-static-where-possible.patch @@ -0,0 +1,591 @@ +commit 6cf6c7ff25c883349e8e9e5468e61498358e2e91 +Author: WGH <wgh@torlan.ru> +Date: Sat Aug 27 17:34:22 2016 +0300 + + added "static" to C functions, where possible + + 1. It reduces clutter in symbol table. + 2. It fixes issues with C99 inline semantics for functions + marked as inline (#237, #180, #222), which manifests + when compiled with GCC>=5. + +diff --git a/lib/ultrajsondec.c b/lib/ultrajsondec.c +index 21a732e..19efc60 100644 +--- a/lib/ultrajsondec.c ++++ b/lib/ultrajsondec.c +@@ -66,7 +66,7 @@ struct DecoderState + JSONObjectDecoder *dec; + }; + +-JSOBJ FASTCALL_MSVC decode_any( struct DecoderState *ds) FASTCALL_ATTR; ++static JSOBJ FASTCALL_MSVC decode_any( struct DecoderState *ds) FASTCALL_ATTR; + typedef JSOBJ (*PFN_DECODER)( struct DecoderState *ds); + + static JSOBJ SetError( struct DecoderState *ds, int offset, const char *message) +@@ -76,13 +76,13 @@ static JSOBJ SetError( struct DecoderState *ds, int offset, const char *message) + return NULL; + } + +-double createDouble(double intNeg, double intValue, double frcValue, int frcDecimalCount) ++static double createDouble(double intNeg, double intValue, double frcValue, int frcDecimalCount) + { + static const double g_pow10[] = {1.0, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001,0.0000001, 0.00000001, 0.000000001, 0.0000000001, 0.00000000001, 0.000000000001, 0.0000000000001, 0.00000000000001, 0.000000000000001}; + return (intValue + (frcValue * g_pow10[frcDecimalCount])) * intNeg; + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decodePreciseFloat(struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decodePreciseFloat(struct DecoderState *ds) + { + char *end; + double value; +@@ -99,7 +99,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decodePreciseFloat(struct DecoderState *ds) + return ds->dec->newDouble(ds->prv, value); + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_numeric (struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_numeric (struct DecoderState *ds) + { + int intNeg = 1; + int mantSize = 0; +@@ -309,7 +309,7 @@ BREAK_EXP_LOOP: + return ds->dec->newDouble (ds->prv, createDouble( (double) intNeg, (double) intValue , frcValue, decimalCount) * pow(10.0, expValue * expNeg)); + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_true ( struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_true ( struct DecoderState *ds) + { + char *offset = ds->start; + offset ++; +@@ -329,7 +329,7 @@ SETERROR: + return SetError(ds, -1, "Unexpected character found when decoding 'true'"); + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_false ( struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_false ( struct DecoderState *ds) + { + char *offset = ds->start; + offset ++; +@@ -351,7 +351,7 @@ SETERROR: + return SetError(ds, -1, "Unexpected character found when decoding 'false'"); + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_null ( struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_null ( struct DecoderState *ds) + { + char *offset = ds->start; + offset ++; +@@ -371,7 +371,7 @@ SETERROR: + return SetError(ds, -1, "Unexpected character found when decoding 'null'"); + } + +-FASTCALL_ATTR void FASTCALL_MSVC SkipWhitespace(struct DecoderState *ds) ++static FASTCALL_ATTR void FASTCALL_MSVC SkipWhitespace(struct DecoderState *ds) + { + char *offset = ds->start; + +@@ -422,7 +422,7 @@ static const JSUINT8 g_decoderLookup[256] = + /* 0xf0 */ 4, 4, 4, 4, 4, 4, 4, 4, DS_UTFLENERROR, DS_UTFLENERROR, DS_UTFLENERROR, DS_UTFLENERROR, DS_UTFLENERROR, DS_UTFLENERROR, DS_UTFLENERROR, DS_UTFLENERROR, + }; + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds) + { + JSUTF16 sur[2] = { 0 }; + int iSur = 0; +@@ -672,7 +672,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds) + } + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_array(struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_array(struct DecoderState *ds) + { + JSOBJ itemValue; + JSOBJ newObj; +@@ -736,7 +736,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_array(struct DecoderState *ds) + } + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_object( struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_object( struct DecoderState *ds) + { + JSOBJ itemName; + JSOBJ itemValue; +@@ -819,7 +819,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_object( struct DecoderState *ds) + } + } + +-FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_any(struct DecoderState *ds) ++static FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_any(struct DecoderState *ds) + { + for (;;) + { +diff --git a/lib/ultrajsonenc.c b/lib/ultrajsonenc.c +index 6c1b120..f330171 100644 +--- a/lib/ultrajsonenc.c ++++ b/lib/ultrajsonenc.c +@@ -112,7 +112,7 @@ static void SetError (JSOBJ obj, JSONObjectEncoder *enc, const char *message) + /* + FIXME: Keep track of how big these get across several encoder calls and try to make an estimate + That way we won't run our head into the wall each call */ +-void Buffer_Realloc (JSONObjectEncoder *enc, size_t cbNeeded) ++static void Buffer_Realloc (JSONObjectEncoder *enc, size_t cbNeeded) + { + size_t curSize = enc->end - enc->start; + size_t newSize = curSize * 2; +@@ -148,7 +148,7 @@ void Buffer_Realloc (JSONObjectEncoder *enc, size_t cbNeeded) + enc->end = enc->start + newSize; + } + +-FASTCALL_ATTR INLINE_PREFIX void FASTCALL_MSVC Buffer_AppendShortHexUnchecked (char *outputOffset, unsigned short value) ++static FASTCALL_ATTR INLINE_PREFIX void FASTCALL_MSVC Buffer_AppendShortHexUnchecked (char *outputOffset, unsigned short value) + { + *(outputOffset++) = g_hexChars[(value & 0xf000) >> 12]; + *(outputOffset++) = g_hexChars[(value & 0x0f00) >> 8]; +@@ -156,7 +156,7 @@ FASTCALL_ATTR INLINE_PREFIX void FASTCALL_MSVC Buffer_AppendShortHexUnchecked (c + *(outputOffset++) = g_hexChars[(value & 0x000f) >> 0]; + } + +-int Buffer_EscapeStringUnvalidated (JSONObjectEncoder *enc, const char *io, const char *end) ++static int Buffer_EscapeStringUnvalidated (JSONObjectEncoder *enc, const char *io, const char *end) + { + char *of = (char *) enc->offset; + +@@ -260,7 +260,7 @@ int Buffer_EscapeStringUnvalidated (JSONObjectEncoder *enc, const char *io, cons + } + } + +-int Buffer_EscapeStringValidated (JSOBJ obj, JSONObjectEncoder *enc, const char *io, const char *end) ++static int Buffer_EscapeStringValidated (JSOBJ obj, JSONObjectEncoder *enc, const char *io, const char *end) + { + JSUTF32 ucs; + char *of = (char *) enc->offset; +@@ -498,19 +498,19 @@ int Buffer_EscapeStringValidated (JSOBJ obj, JSONObjectEncoder *enc, const char + #define Buffer_AppendCharUnchecked(__enc, __chr) \ + *((__enc)->offset++) = __chr; \ + +-FASTCALL_ATTR INLINE_PREFIX void FASTCALL_MSVC strreverse(char* begin, char* end) ++static FASTCALL_ATTR INLINE_PREFIX void FASTCALL_MSVC strreverse(char* begin, char* end) + { + char aux; + while (end > begin) + aux = *end, *end-- = *begin, *begin++ = aux; + } + +-void Buffer_AppendIndentNewlineUnchecked(JSONObjectEncoder *enc) ++static void Buffer_AppendIndentNewlineUnchecked(JSONObjectEncoder *enc) + { + if (enc->indent > 0) Buffer_AppendCharUnchecked(enc, '\n'); + } + +-void Buffer_AppendIndentUnchecked(JSONObjectEncoder *enc, JSINT32 value) ++static void Buffer_AppendIndentUnchecked(JSONObjectEncoder *enc, JSINT32 value) + { + int i; + if (enc->indent > 0) +@@ -519,7 +519,7 @@ void Buffer_AppendIndentUnchecked(JSONObjectEncoder *enc, JSINT32 value) + Buffer_AppendCharUnchecked(enc, ' '); + } + +-void Buffer_AppendIntUnchecked(JSONObjectEncoder *enc, JSINT32 value) ++static void Buffer_AppendIntUnchecked(JSONObjectEncoder *enc, JSINT32 value) + { + char* wstr; + JSUINT32 uvalue = (value < 0) ? -value : value; +@@ -535,7 +535,7 @@ void Buffer_AppendIntUnchecked(JSONObjectEncoder *enc, JSINT32 value) + enc->offset += (wstr - (enc->offset)); + } + +-void Buffer_AppendLongUnchecked(JSONObjectEncoder *enc, JSINT64 value) ++static void Buffer_AppendLongUnchecked(JSONObjectEncoder *enc, JSINT64 value) + { + char* wstr; + JSUINT64 uvalue = (value < 0) ? -value : value; +@@ -551,7 +551,7 @@ void Buffer_AppendLongUnchecked(JSONObjectEncoder *enc, JSINT64 value) + enc->offset += (wstr - (enc->offset)); + } + +-void Buffer_AppendUnsignedLongUnchecked(JSONObjectEncoder *enc, JSUINT64 value) ++static void Buffer_AppendUnsignedLongUnchecked(JSONObjectEncoder *enc, JSUINT64 value) + { + char* wstr; + JSUINT64 uvalue = value; +@@ -566,7 +566,7 @@ void Buffer_AppendUnsignedLongUnchecked(JSONObjectEncoder *enc, JSUINT64 value) + enc->offset += (wstr - (enc->offset)); + } + +-int Buffer_AppendDoubleUnchecked(JSOBJ obj, JSONObjectEncoder *enc, double value) ++static int Buffer_AppendDoubleUnchecked(JSOBJ obj, JSONObjectEncoder *enc, double value) + { + /* if input is larger than thres_max, revert to exponential */ + const double thres_max = (double) 1e16 - 1; +@@ -714,7 +714,7 @@ Handle integration functions returning NULL here */ + FIXME: + Perhaps implement recursion detection */ + +-void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName) ++static void encode(JSOBJ obj, JSONObjectEncoder *enc, const char *name, size_t cbName) + { + const char *value; + char *objName; +diff --git a/python/JSONtoObj.c b/python/JSONtoObj.c +index 79d9f1a..6cef088 100644 +--- a/python/JSONtoObj.c ++++ b/python/JSONtoObj.c +@@ -43,7 +43,7 @@ http://www.opensource.apple.com/source/tcl/tcl-14/tcl/license.terms + //#define PRINTMARK() fprintf(stderr, "%s: MARK(%d)\n", __FILE__, __LINE__) + #define PRINTMARK() + +-void Object_objectAddKey(void *prv, JSOBJ obj, JSOBJ name, JSOBJ value) ++static void Object_objectAddKey(void *prv, JSOBJ obj, JSOBJ name, JSOBJ value) + { + PyDict_SetItem (obj, name, value); + Py_DECREF( (PyObject *) name); +@@ -51,59 +51,59 @@ void Object_objectAddKey(void *prv, JSOBJ obj, JSOBJ name, JSOBJ value) + return; + } + +-void Object_arrayAddItem(void *prv, JSOBJ obj, JSOBJ value) ++static void Object_arrayAddItem(void *prv, JSOBJ obj, JSOBJ value) + { + PyList_Append(obj, value); + Py_DECREF( (PyObject *) value); + return; + } + +-JSOBJ Object_newString(void *prv, wchar_t *start, wchar_t *end) ++static JSOBJ Object_newString(void *prv, wchar_t *start, wchar_t *end) + { + return PyUnicode_FromWideChar (start, (end - start)); + } + +-JSOBJ Object_newTrue(void *prv) ++static JSOBJ Object_newTrue(void *prv) + { + Py_RETURN_TRUE; + } + +-JSOBJ Object_newFalse(void *prv) ++static JSOBJ Object_newFalse(void *prv) + { + Py_RETURN_FALSE; + } + +-JSOBJ Object_newNull(void *prv) ++static JSOBJ Object_newNull(void *prv) + { + Py_RETURN_NONE; + } + +-JSOBJ Object_newObject(void *prv) ++static JSOBJ Object_newObject(void *prv) + { + return PyDict_New(); + } + +-JSOBJ Object_newArray(void *prv) ++static JSOBJ Object_newArray(void *prv) + { + return PyList_New(0); + } + +-JSOBJ Object_newInteger(void *prv, JSINT32 value) ++static JSOBJ Object_newInteger(void *prv, JSINT32 value) + { + return PyInt_FromLong( (long) value); + } + +-JSOBJ Object_newLong(void *prv, JSINT64 value) ++static JSOBJ Object_newLong(void *prv, JSINT64 value) + { + return PyLong_FromLongLong (value); + } + +-JSOBJ Object_newUnsignedLong(void *prv, JSUINT64 value) ++static JSOBJ Object_newUnsignedLong(void *prv, JSUINT64 value) + { + return PyLong_FromUnsignedLongLong (value); + } + +-JSOBJ Object_newDouble(void *prv, double value) ++static JSOBJ Object_newDouble(void *prv, double value) + { + return PyFloat_FromDouble(value); + } +diff --git a/python/objToJSON.c b/python/objToJSON.c +index 04a4575..1960d40 100644 +--- a/python/objToJSON.c ++++ b/python/objToJSON.c +@@ -226,7 +226,7 @@ static void *PyDateToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size + return NULL; + } + +-int Tuple_iterNext(JSOBJ obj, JSONTypeContext *tc) ++static int Tuple_iterNext(JSOBJ obj, JSONTypeContext *tc) + { + PyObject *item; + +@@ -242,21 +242,21 @@ int Tuple_iterNext(JSOBJ obj, JSONTypeContext *tc) + return 1; + } + +-void Tuple_iterEnd(JSOBJ obj, JSONTypeContext *tc) ++static void Tuple_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + } + +-JSOBJ Tuple_iterGetValue(JSOBJ obj, JSONTypeContext *tc) ++static JSOBJ Tuple_iterGetValue(JSOBJ obj, JSONTypeContext *tc) + { + return GET_TC(tc)->itemValue; + } + +-char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) ++static char *Tuple_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + { + return NULL; + } + +-int Iter_iterNext(JSOBJ obj, JSONTypeContext *tc) ++static int Iter_iterNext(JSOBJ obj, JSONTypeContext *tc) + { + PyObject *item; + +@@ -282,7 +282,7 @@ int Iter_iterNext(JSOBJ obj, JSONTypeContext *tc) + return 1; + } + +-void Iter_iterEnd(JSOBJ obj, JSONTypeContext *tc) ++static void Iter_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + if (GET_TC(tc)->itemValue) + { +@@ -297,17 +297,17 @@ void Iter_iterEnd(JSOBJ obj, JSONTypeContext *tc) + } + } + +-JSOBJ Iter_iterGetValue(JSOBJ obj, JSONTypeContext *tc) ++static JSOBJ Iter_iterGetValue(JSOBJ obj, JSONTypeContext *tc) + { + return GET_TC(tc)->itemValue; + } + +-char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) ++static char *Iter_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + { + return NULL; + } + +-void Dir_iterEnd(JSOBJ obj, JSONTypeContext *tc) ++static void Dir_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + if (GET_TC(tc)->itemValue) + { +@@ -325,7 +325,7 @@ void Dir_iterEnd(JSOBJ obj, JSONTypeContext *tc) + PRINTMARK(); + } + +-int Dir_iterNext(JSOBJ _obj, JSONTypeContext *tc) ++static int Dir_iterNext(JSOBJ _obj, JSONTypeContext *tc) + { + PyObject *obj = (PyObject *) _obj; + PyObject *itemValue = GET_TC(tc)->itemValue; +@@ -401,20 +401,20 @@ int Dir_iterNext(JSOBJ _obj, JSONTypeContext *tc) + return 1; + } + +-JSOBJ Dir_iterGetValue(JSOBJ obj, JSONTypeContext *tc) ++static JSOBJ Dir_iterGetValue(JSOBJ obj, JSONTypeContext *tc) + { + PRINTMARK(); + return GET_TC(tc)->itemValue; + } + +-char *Dir_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) ++static char *Dir_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + { + PRINTMARK(); + *outLen = PyString_GET_SIZE(GET_TC(tc)->itemName); + return PyString_AS_STRING(GET_TC(tc)->itemName); + } + +-int List_iterNext(JSOBJ obj, JSONTypeContext *tc) ++static int List_iterNext(JSOBJ obj, JSONTypeContext *tc) + { + if (GET_TC(tc)->index >= GET_TC(tc)->size) + { +@@ -427,16 +427,16 @@ int List_iterNext(JSOBJ obj, JSONTypeContext *tc) + return 1; + } + +-void List_iterEnd(JSOBJ obj, JSONTypeContext *tc) ++static void List_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + } + +-JSOBJ List_iterGetValue(JSOBJ obj, JSONTypeContext *tc) ++static JSOBJ List_iterGetValue(JSOBJ obj, JSONTypeContext *tc) + { + return GET_TC(tc)->itemValue; + } + +-char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) ++static char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + { + return NULL; + } +@@ -447,7 +447,7 @@ char *List_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + // itemValue is borrowed from object (which is dict). No refCounting + //============================================================================= + +-int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) ++static int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) + { + #if PY_MAJOR_VERSION >= 3 + PyObject* itemNameTmp; +@@ -488,7 +488,7 @@ int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc) + return 1; + } + +-void Dict_iterEnd(JSOBJ obj, JSONTypeContext *tc) ++static void Dict_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + if (GET_TC(tc)->itemName) + { +@@ -499,18 +499,18 @@ void Dict_iterEnd(JSOBJ obj, JSONTypeContext *tc) + PRINTMARK(); + } + +-JSOBJ Dict_iterGetValue(JSOBJ obj, JSONTypeContext *tc) ++static JSOBJ Dict_iterGetValue(JSOBJ obj, JSONTypeContext *tc) + { + return GET_TC(tc)->itemValue; + } + +-char *Dict_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) ++static char *Dict_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + { + *outLen = PyString_GET_SIZE(GET_TC(tc)->itemName); + return PyString_AS_STRING(GET_TC(tc)->itemName); + } + +-int SortedDict_iterNext(JSOBJ obj, JSONTypeContext *tc) ++static int SortedDict_iterNext(JSOBJ obj, JSONTypeContext *tc) + { + PyObject *items = NULL, *item = NULL, *key = NULL, *value = NULL; + Py_ssize_t i, nitems; +@@ -603,7 +603,7 @@ error: + return -1; + } + +-void SortedDict_iterEnd(JSOBJ obj, JSONTypeContext *tc) ++static void SortedDict_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + GET_TC(tc)->itemName = NULL; + GET_TC(tc)->itemValue = NULL; +@@ -612,19 +612,19 @@ void SortedDict_iterEnd(JSOBJ obj, JSONTypeContext *tc) + PRINTMARK(); + } + +-JSOBJ SortedDict_iterGetValue(JSOBJ obj, JSONTypeContext *tc) ++static JSOBJ SortedDict_iterGetValue(JSOBJ obj, JSONTypeContext *tc) + { + return GET_TC(tc)->itemValue; + } + +-char *SortedDict_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) ++static char *SortedDict_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + { + *outLen = PyString_GET_SIZE(GET_TC(tc)->itemName); + return PyString_AS_STRING(GET_TC(tc)->itemName); + } + + +-void SetupDictIter(PyObject *dictObj, TypeContext *pc, JSONObjectEncoder *enc) ++static void SetupDictIter(PyObject *dictObj, TypeContext *pc, JSONObjectEncoder *enc) + { + if (enc->sortKeys) { + pc->iterEnd = SortedDict_iterEnd; +@@ -642,7 +642,7 @@ void SetupDictIter(PyObject *dictObj, TypeContext *pc, JSONObjectEncoder *enc) + pc->index = 0; + } + +-void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObjectEncoder *enc) ++static void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObjectEncoder *enc) + { + PyObject *obj, *exc, *iter; + TypeContext *pc; +@@ -929,7 +929,7 @@ INVALID: + return; + } + +-void Object_endTypeContext(JSOBJ obj, JSONTypeContext *tc) ++static void Object_endTypeContext(JSOBJ obj, JSONTypeContext *tc) + { + Py_XDECREF(GET_TC(tc)->newObj); + +@@ -937,33 +937,33 @@ void Object_endTypeContext(JSOBJ obj, JSONTypeContext *tc) + tc->prv = NULL; + } + +-const char *Object_getStringValue(JSOBJ obj, JSONTypeContext *tc, size_t *_outLen) ++static const char *Object_getStringValue(JSOBJ obj, JSONTypeContext *tc, size_t *_outLen) + { + return GET_TC(tc)->PyTypeToJSON (obj, tc, NULL, _outLen); + } + +-JSINT64 Object_getLongValue(JSOBJ obj, JSONTypeContext *tc) ++static JSINT64 Object_getLongValue(JSOBJ obj, JSONTypeContext *tc) + { + JSINT64 ret; + GET_TC(tc)->PyTypeToJSON (obj, tc, &ret, NULL); + return ret; + } + +-JSUINT64 Object_getUnsignedLongValue(JSOBJ obj, JSONTypeContext *tc) ++static JSUINT64 Object_getUnsignedLongValue(JSOBJ obj, JSONTypeContext *tc) + { + JSUINT64 ret; + GET_TC(tc)->PyTypeToJSON (obj, tc, &ret, NULL); + return ret; + } + +-JSINT32 Object_getIntValue(JSOBJ obj, JSONTypeContext *tc) ++static JSINT32 Object_getIntValue(JSOBJ obj, JSONTypeContext *tc) + { + JSINT32 ret; + GET_TC(tc)->PyTypeToJSON (obj, tc, &ret, NULL); + return ret; + } + +-double Object_getDoubleValue(JSOBJ obj, JSONTypeContext *tc) ++static double Object_getDoubleValue(JSOBJ obj, JSONTypeContext *tc) + { + double ret; + GET_TC(tc)->PyTypeToJSON (obj, tc, &ret, NULL); +@@ -975,22 +975,22 @@ static void Object_releaseObject(JSOBJ _obj) + Py_DECREF( (PyObject *) _obj); + } + +-int Object_iterNext(JSOBJ obj, JSONTypeContext *tc) ++static int Object_iterNext(JSOBJ obj, JSONTypeContext *tc) + { + return GET_TC(tc)->iterNext(obj, tc); + } + +-void Object_iterEnd(JSOBJ obj, JSONTypeContext *tc) ++static void Object_iterEnd(JSOBJ obj, JSONTypeContext *tc) + { + GET_TC(tc)->iterEnd(obj, tc); + } + +-JSOBJ Object_iterGetValue(JSOBJ obj, JSONTypeContext *tc) ++static JSOBJ Object_iterGetValue(JSOBJ obj, JSONTypeContext *tc) + { + return GET_TC(tc)->iterGetValue(obj, tc); + } + +-char *Object_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) ++static char *Object_iterGetName(JSOBJ obj, JSONTypeContext *tc, size_t *outLen) + { + return GET_TC(tc)->iterGetName(obj, tc, outLen); + } diff --git a/dev-python/ujson/metadata.xml b/dev-python/ujson/metadata.xml new file mode 100644 index 000000000000..54e7ce8dfd4b --- /dev/null +++ b/dev-python/ujson/metadata.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>swegener@gentoo.org</email> + <name>Sven Wegener</name> + </maintainer> + <maintainer type="project"> + <email>python@gentoo.org</email> + <name>Python</name> + </maintainer> + <upstream> + <remote-id type="pypi">ujson</remote-id> + </upstream> +</pkgmetadata> diff --git a/dev-python/ujson/ujson-1.33.ebuild b/dev-python/ujson/ujson-1.33.ebuild new file mode 100644 index 000000000000..8c49a7e6fe88 --- /dev/null +++ b/dev-python/ujson/ujson-1.33.ebuild @@ -0,0 +1,44 @@ +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=5 + +# One test; FAIL: test_encodeToUTF8 (__main__.UltraJSONTests) under py2.5. +# Fix and repair and re-insert if it's REALLY needed +PYTHON_COMPAT=( python2_7 python3_{4,5} ) + +inherit distutils-r1 + +DESCRIPTION="Ultra fast JSON encoder and decoder for Python" +HOMEPAGE="https://pypi.python.org/pypi/ujson/" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.zip" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="amd64 arm x86" +IUSE="test" + +DEPEND=" + dev-python/setuptools[${PYTHON_USEDEP}] + dev-python/nose[${PYTHON_USEDEP}] + app-arch/unzip" +RDEPEND="${DEPEND}" + +PATCHES=( + "${FILESDIR}"/${P}-test-py3.patch +) + +python_test() { + # See setup.py; line 72. Again "${S}" is used for reading tests + # Since py3_2 is first in the queue it needs its own copy + # or else all py2s to follow will be reading read py3 tests + if [[ "${EPYTHON}" =~ 'python3' ]]; then + cd "${BUILD_DIR}"/lib || die + cp -a "${S}"/tests/ . || die + 2to3 -w tests/tests.py || die + "${PYTHON}" tests/tests.py || die + rm -rf tests/ || die + else + "${PYTHON}" tests/tests.py || die + fi +} diff --git a/dev-python/ujson/ujson-1.35.ebuild b/dev-python/ujson/ujson-1.35.ebuild new file mode 100644 index 000000000000..19d94beed916 --- /dev/null +++ b/dev-python/ujson/ujson-1.35.ebuild @@ -0,0 +1,33 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 +PYTHON_COMPAT=( python2_7 python3_{4,5,6} ) + +inherit distutils-r1 + +DESCRIPTION="Ultra fast JSON encoder and decoder for Python" +HOMEPAGE="https://pypi.python.org/pypi/ujson/" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~amd64 ~arm ~x86" +IUSE="test" + +DEPEND=" + dev-python/setuptools[${PYTHON_USEDEP}]" +RDEPEND="${DEPEND}" + +PATCHES=( + "${FILESDIR}/${P}-sort_keys-segfault.patch" + "${FILESDIR}/${P}-use-static-where-possible.patch" + "${FILESDIR}/${P}-fix-for-overflowing-long.patch" + "${FILESDIR}/${P}-standard-handling-of-none.patch" + "${FILESDIR}/${P}-fix-ordering-of-orderdict.patch" + "${FILESDIR}/${P}-test-depricationwarning.patch" +) + +python_test() { + "${PYTHON}" tests/tests.py || die +} |