From d0603d178305ee00a89ecd947e5e205f2034a7b6d9b2b0d31e97402b2a88bc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Tue, 14 May 2019 21:40:56 +0000 Subject: [PATCH] Accepting request 702069 from home:jayvdb:django - Rename package from python-cjson to python-python-cjson - Add Python 3 support using py3.patch - Update to v1.2.1 OBS-URL: https://build.opensuse.org/request/show/702069 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-cjson?expand=0&rev=1 --- .gitattributes | 23 ++ .gitignore | 1 + py3.patch | 645 ++++++++++++++++++++++++++++++++++++ python-cjson-1.2.1.tar.gz | 3 + python-python-cjson.changes | 57 ++++ python-python-cjson.spec | 85 +++++ 6 files changed, 814 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 py3.patch create mode 100644 python-cjson-1.2.1.tar.gz create mode 100644 python-python-cjson.changes create mode 100644 python-python-cjson.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/py3.patch b/py3.patch new file mode 100644 index 0000000..9beb985 --- /dev/null +++ b/py3.patch @@ -0,0 +1,645 @@ +From f9060f9981dfc6bc7aed6ced93f10477b0a77d60 Mon Sep 17 00:00:00 2001 +From: Felipe Machado +Date: Wed, 9 Aug 2017 15:48:27 -0300 +Subject: [PATCH] Python 3 support - initial attempt + +--- + cjson.c | 268 ++++++++++++++++++++++++++-------------------------- + jsontest.py | 16 ++-- + 2 files changed, 144 insertions(+), 140 deletions(-) + +diff --git a/cjson.c b/cjson.c +index d3ecc81..a44e7e4 100644 +--- a/cjson.c ++++ b/cjson.c +@@ -8,6 +8,16 @@ + #include + #include + ++#if PY_MAJOR_VERSION >= 3 ++#define IS_PY3K ++#endif ++ ++#if PY_MAJOR_VERSION >= 3 ++#define STRING_TYPE PyUnicodeObject ++#else ++#define STRING_TYPE PyStringObject ++#endif ++ + typedef struct JSONData { + char *str; // the actual json string + char *end; // pointer to the string end +@@ -16,7 +26,6 @@ typedef struct JSONData { + } JSONData; + + static PyObject* encode_object(PyObject *object); +-static PyObject* encode_string(PyObject *object); + static PyObject* encode_unicode(PyObject *object); + static PyObject* encode_tuple(PyObject *object); + static PyObject* encode_list(PyObject *object); +@@ -68,6 +77,17 @@ typedef int Py_ssize_t; + #define skipSpaces(d) while(isspace(*((d)->ptr))) (d)->ptr++ + + ++static inline void ++PyUnicode_ConcatAndDel(PyObject **left, PyObject *right) ++{ ++ PyObject *newobj; ++ newobj = PyUnicode_Concat(*left, right); ++ Py_DECREF(*left); ++ Py_DECREF(right); ++ *left = newobj; ++} ++ ++ + /* ------------------------------ Decoding ----------------------------- */ + + static PyObject* +@@ -161,12 +181,7 @@ decode_string(JSONData *jsondata) + + len = ptr - jsondata->ptr - 1; + +- if (has_unicode || jsondata->all_unicode) +- object = PyUnicode_DecodeUnicodeEscape(jsondata->ptr+1, len, NULL); +- else if (string_escape) +- object = PyString_DecodeEscape(jsondata->ptr+1, len, NULL, 0, NULL); +- else +- object = PyString_FromStringAndSize(jsondata->ptr+1, len); ++ object = PyUnicode_DecodeUnicodeEscape(jsondata->ptr+1, len, NULL); + + if (object == NULL) { + PyObject *type, *value, *tb, *reason; +@@ -182,7 +197,7 @@ decode_string(JSONData *jsondata) + PyErr_Format(JSON_DecodeError, "cannot decode string starting" + " at position " SSIZE_T_F ": %s", + (Py_ssize_t)(jsondata->ptr - jsondata->str), +- reason ? PyString_AsString(reason) : "bad format"); ++ reason ? PyUnicode_AsUTF8(reason) : "bad format"); + Py_XDECREF(reason); + } else { + PyErr_Format(JSON_DecodeError, +@@ -292,14 +307,14 @@ decode_number(JSONData *jsondata) + skipDigits(ptr); + } + +- str = PyString_FromStringAndSize(jsondata->ptr, ptr - jsondata->ptr); ++ str = PyUnicode_FromStringAndSize(jsondata->ptr, ptr - jsondata->ptr); + if (str == NULL) + return NULL; + + if (is_float) +- object = PyFloat_FromString(str, NULL); ++ object = PyFloat_FromString(str); + else +- object = PyInt_FromString(PyString_AS_STRING(str), NULL, 10); ++ object = PyLong_FromUnicodeObject(str, 10); + + Py_DECREF(str); + +@@ -579,75 +594,6 @@ decode_json(JSONData *jsondata) + + /* ------------------------------ Encoding ----------------------------- */ + +-/* +- * This function is an almost verbatim copy of PyString_Repr() from +- * Python's stringobject.c with the following differences: +- * +- * - it always quotes the output using double quotes. +- * - it also quotes \b and \f +- * - it replaces any non ASCII character hh with \u00hh instead of \xhh +- */ +-static PyObject* +-encode_string(PyObject *string) +-{ +- register PyStringObject* op = (PyStringObject*) string; +- size_t newsize = 2 + 6 * op->ob_size; +- PyObject *v; +- +- if (op->ob_size > (PY_SSIZE_T_MAX-2)/6) { +- PyErr_SetString(PyExc_OverflowError, +- "string is too large to make repr"); +- return NULL; +- } +- v = PyString_FromStringAndSize((char *)NULL, newsize); +- if (v == NULL) { +- return NULL; +- } +- else { +- register Py_ssize_t i; +- register char c; +- register char *p; +- int quote; +- +- quote = '"'; +- +- p = PyString_AS_STRING(v); +- *p++ = quote; +- for (i = 0; i < op->ob_size; i++) { +- /* There's at least enough room for a hex escape +- and a closing quote. */ +- assert(newsize - (p - PyString_AS_STRING(v)) >= 7); +- c = op->ob_sval[i]; +- if (c == quote || c == '\\') +- *p++ = '\\', *p++ = c; +- else if (c == '\t') +- *p++ = '\\', *p++ = 't'; +- else if (c == '\n') +- *p++ = '\\', *p++ = 'n'; +- else if (c == '\r') +- *p++ = '\\', *p++ = 'r'; +- else if (c == '\f') +- *p++ = '\\', *p++ = 'f'; +- else if (c == '\b') +- *p++ = '\\', *p++ = 'b'; +- else if (c < ' ' || c >= 0x7f) { +- /* For performance, we don't want to call +- * PyOS_snprintf here (extra layers of +- * function call). */ +- sprintf(p, "\\u%04x", c & 0xff); +- p += 6; +- } +- else +- *p++ = c; +- } +- assert(newsize - (p - PyString_AS_STRING(v)) >= 1); +- *p++ = quote; +- *p = '\0'; +- _PyString_Resize(&v, (int) (p - PyString_AS_STRING(v))); +- return v; +- } +-} +- + /* + * This function is an almost verbatim copy of unicodeescape_string() from + * Python's unicodeobject.c with the following differences: +@@ -662,7 +608,7 @@ encode_unicode(PyObject *unicode) + PyObject *repr; + Py_UNICODE *s; + Py_ssize_t size; +- char *p; ++ Py_UNICODE *p; + + static const char *hexdigit = "0123456789abcdef"; + #ifdef Py_UNICODE_WIDE +@@ -694,11 +640,11 @@ encode_unicode(PyObject *unicode) + return NULL; + } + +- repr = PyString_FromStringAndSize(NULL, 2 + expandsize*size + 1); ++ repr = PyUnicode_FromStringAndSize(NULL, 2 + expandsize*size + 1); + if (repr == NULL) + return NULL; + +- p = PyString_AS_STRING(repr); ++ p = PyUnicode_AS_UNICODE(repr); + + *p++ = '"'; + +@@ -706,7 +652,7 @@ encode_unicode(PyObject *unicode) + Py_UNICODE ch = *s++; + + /* Escape quotes */ +- if ((ch == (Py_UNICODE) PyString_AS_STRING(repr)[0] || ch == '\\')) { ++ if ((ch == (Py_UNICODE) PyUnicode_AS_UNICODE(repr)[0] || ch == '\\')) { + *p++ = '\\'; + *p++ = (char) ch; + continue; +@@ -801,10 +747,11 @@ encode_unicode(PyObject *unicode) + *p++ = (char) ch; + } + +- *p++ = PyString_AS_STRING(repr)[0]; ++ *p++ = PyUnicode_AS_UNICODE(repr)[0]; + + *p = '\0'; +- _PyString_Resize(&repr, p - PyString_AS_STRING(repr)); ++ PyUnicode_Resize(&repr, p - PyUnicode_AS_UNICODE(repr)); ++ + return repr; + } + +@@ -825,9 +772,9 @@ encode_tuple(PyObject *tuple) + PyObject *pieces, *result = NULL; + PyTupleObject *v = (PyTupleObject*) tuple; + +- n = v->ob_size; ++ n = v->ob_base.ob_size; + if (n == 0) +- return PyString_FromString("[]"); ++ return PyUnicode_FromString("[]"); + + pieces = PyTuple_New(n); + if (pieces == NULL) +@@ -843,29 +790,29 @@ encode_tuple(PyObject *tuple) + + /* Add "[]" decorations to the first and last items. */ + assert(n > 0); +- s = PyString_FromString("["); ++ s = PyUnicode_FromString("["); + if (s == NULL) + goto Done; + temp = PyTuple_GET_ITEM(pieces, 0); +- PyString_ConcatAndDel(&s, temp); ++ PyUnicode_ConcatAndDel(&s, temp); + PyTuple_SET_ITEM(pieces, 0, s); + if (s == NULL) + goto Done; + +- s = PyString_FromString("]"); ++ s = PyUnicode_FromString("]"); + if (s == NULL) + goto Done; + temp = PyTuple_GET_ITEM(pieces, n-1); +- PyString_ConcatAndDel(&temp, s); ++ PyUnicode_ConcatAndDel(&temp, s); + PyTuple_SET_ITEM(pieces, n-1, temp); + if (temp == NULL) + goto Done; + + /* Paste them all together with ", " between. */ +- s = PyString_FromString(", "); ++ s = PyUnicode_FromString(", "); + if (s == NULL) + goto Done; +- result = _PyString_Join(s, pieces); ++ result = PyUnicode_Join(s, pieces); + Py_DECREF(s); + + Done: +@@ -899,8 +846,8 @@ encode_list(PyObject *list) + return NULL; + } + +- if (v->ob_size == 0) { +- result = PyString_FromString("[]"); ++ if (v->ob_base.ob_size == 0) { ++ result = PyUnicode_FromString("[]"); + goto Done; + } + +@@ -910,7 +857,7 @@ encode_list(PyObject *list) + + /* Do repr() on each element. Note that this may mutate the list, + * so must refetch the list size on each iteration. */ +- for (i = 0; i < v->ob_size; ++i) { ++ for (i = 0; i < v->ob_base.ob_size; ++i) { + int status; + s = encode_object(v->ob_item[i]); + if (s == NULL) +@@ -923,29 +870,29 @@ encode_list(PyObject *list) + + /* Add "[]" decorations to the first and last items. */ + assert(PyList_GET_SIZE(pieces) > 0); +- s = PyString_FromString("["); ++ s = PyUnicode_FromString("["); + if (s == NULL) + goto Done; + temp = PyList_GET_ITEM(pieces, 0); +- PyString_ConcatAndDel(&s, temp); ++ PyUnicode_ConcatAndDel(&s, temp); + PyList_SET_ITEM(pieces, 0, s); + if (s == NULL) + goto Done; + +- s = PyString_FromString("]"); ++ s = PyUnicode_FromString("]"); + if (s == NULL) + goto Done; + temp = PyList_GET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1); +- PyString_ConcatAndDel(&temp, s); ++ PyUnicode_ConcatAndDel(&temp, s); + PyList_SET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1, temp); + if (temp == NULL) + goto Done; + + /* Paste them all together with ", " between. */ +- s = PyString_FromString(", "); ++ s = PyUnicode_FromString(", "); + if (s == NULL) + goto Done; +- result = _PyString_Join(s, pieces); ++ result = PyUnicode_Join(s, pieces); + Py_DECREF(s); + + Done: +@@ -984,7 +931,7 @@ encode_dict(PyObject *dict) + } + + if (mp->ma_used == 0) { +- result = PyString_FromString("{}"); ++ result = PyUnicode_FromString("{}"); + goto Done; + } + +@@ -992,7 +939,7 @@ encode_dict(PyObject *dict) + if (pieces == NULL) + goto Done; + +- colon = PyString_FromString(": "); ++ colon = PyUnicode_FromString(": "); + if (colon == NULL) + goto Done; + +@@ -1002,7 +949,7 @@ encode_dict(PyObject *dict) + while (PyDict_Next((PyObject *)mp, &i, &key, &value)) { + int status; + +- if (!PyString_Check(key) && !PyUnicode_Check(key)) { ++ if (!PyUnicode_Check(key)) { + PyErr_SetString(JSON_EncodeError, "JSON encodable dictionaries " + "must have string/unicode keys"); + goto Done; +@@ -1010,9 +957,10 @@ encode_dict(PyObject *dict) + + /* Prevent repr from deleting value during key format. */ + Py_INCREF(value); +- s = encode_object(key); +- PyString_Concat(&s, colon); +- PyString_ConcatAndDel(&s, encode_object(value)); ++ temp = encode_object(key); ++ s = PyUnicode_Concat(temp, colon); ++ Py_DECREF(temp); ++ PyUnicode_ConcatAndDel(&s, encode_object(value)); + Py_DECREF(value); + if (s == NULL) + goto Done; +@@ -1024,35 +972,36 @@ encode_dict(PyObject *dict) + + /* Add "{}" decorations to the first and last items. */ + assert(PyList_GET_SIZE(pieces) > 0); +- s = PyString_FromString("{"); ++ s = PyUnicode_FromString("{"); + if (s == NULL) + goto Done; + temp = PyList_GET_ITEM(pieces, 0); +- PyString_ConcatAndDel(&s, temp); ++ PyUnicode_ConcatAndDel(&s, temp); + PyList_SET_ITEM(pieces, 0, s); + if (s == NULL) + goto Done; + +- s = PyString_FromString("}"); ++ s = PyUnicode_FromString("}"); + if (s == NULL) + goto Done; + temp = PyList_GET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1); +- PyString_ConcatAndDel(&temp, s); ++ PyUnicode_ConcatAndDel(&temp, s); + PyList_SET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1, temp); + if (temp == NULL) + goto Done; + + /* Paste them all together with ", " between. */ +- s = PyString_FromString(", "); ++ s = PyUnicode_FromString(", "); + if (s == NULL) + goto Done; +- result = _PyString_Join(s, pieces); ++ result = PyUnicode_Join(s, pieces); + Py_DECREF(s); + + Done: + Py_XDECREF(pieces); + Py_XDECREF(colon); + Py_ReprLeave((PyObject *)mp); ++ + return result; + } + +@@ -1061,29 +1010,27 @@ static PyObject* + encode_object(PyObject *object) + { + if (object == Py_True) { +- return PyString_FromString("true"); ++ return PyUnicode_FromString("true"); + } else if (object == Py_False) { +- return PyString_FromString("false"); ++ return PyUnicode_FromString("false"); + } else if (object == Py_None) { +- return PyString_FromString("null"); +- } else if (PyString_Check(object)) { +- return encode_string(object); ++ return PyUnicode_FromString("null"); + } else if (PyUnicode_Check(object)) { + return encode_unicode(object); + } else if (PyFloat_Check(object)) { + double val = PyFloat_AS_DOUBLE(object); + if (Py_IS_NAN(val)) { +- return PyString_FromString("NaN"); ++ return PyUnicode_FromString("NaN"); + } else if (Py_IS_INFINITY(val)) { + if (val > 0) { +- return PyString_FromString("Infinity"); ++ return PyUnicode_FromString("Infinity"); + } else { +- return PyString_FromString("-Infinity"); ++ return PyUnicode_FromString("-Infinity"); + } + } else { + return PyObject_Repr(object); + } +- } else if (PyInt_Check(object) || PyLong_Check(object)) { ++ } else if (PyLong_Check(object)) { + return PyObject_Str(object); + } else if (PyList_Check(object)) { + PyObject *result; +@@ -1130,6 +1077,7 @@ JSON_decode(PyObject *self, PyObject *args, PyObject *kwargs) + static char *kwlist[] = {"json", "all_unicode", NULL}; + int all_unicode = False; // by default return unicode only when needed + PyObject *object, *string, *str; ++ Py_ssize_t str_size; + JSONData jsondata; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|i:decode", kwlist, +@@ -1146,13 +1094,13 @@ JSON_decode(PyObject *self, PyObject *args, PyObject *kwargs) + str = string; + } + +- if (PyString_AsStringAndSize(str, &(jsondata.str), NULL) == -1) { ++ if (PyBytes_AsStringAndSize(str, &(jsondata.str), &str_size) == -1) { + Py_DECREF(str); + return NULL; // not a string object or it contains null bytes + } + + jsondata.ptr = jsondata.str; +- jsondata.end = jsondata.str + PyString_GET_SIZE(str); ++ jsondata.end = jsondata.str + str_size; + jsondata.all_unicode = all_unicode; + + object = decode_json(&jsondata); +@@ -1198,37 +1146,93 @@ PyDoc_STRVAR(module_doc, + + /* Initialization function for the module (*must* be called initcjson) */ + ++struct module_state { ++ PyObject *error; ++}; ++ ++#if PY_MAJOR_VERSION >= 3 ++//############################################################################# ++//# PYTHON 3 ################################################################## ++//############################################################################# ++ ++#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) ++ ++static int cjson_traverse(PyObject *m, visitproc visit, void *arg) { ++ Py_VISIT(GETSTATE(m)->error); ++ return 0; ++} ++ ++static int cjson_clear(PyObject *m) { ++ Py_CLEAR(GETSTATE(m)->error); ++ return 0; ++} ++ ++ ++static struct PyModuleDef moduledef = { ++ PyModuleDef_HEAD_INIT, ++ "cjson", ++ module_doc, ++ sizeof(struct module_state), ++ cjson_methods, ++ NULL, ++ cjson_traverse, ++ cjson_clear, ++ NULL ++}; ++ ++#define INITERROR return NULL ++ ++PyMODINIT_FUNC ++PyInit_cjson(void) ++//############################################################################# ++#else ++//############################################################################# ++//# PYTHON 2 ################################################################## ++//############################################################################# ++ ++#define GETSTATE(m) (&_state) ++static struct module_state _state; ++ ++#define INITERROR return ++ + PyMODINIT_FUNC + initcjson(void) ++//############################################################################# ++#endif + { + PyObject *m; + ++#if PY_MAJOR_VERSION >= 3 ++ m = PyModule_Create(&moduledef); ++#else + m = Py_InitModule3("cjson", cjson_methods, module_doc); ++#endif + + if (m == NULL) +- return; ++ INITERROR; + + JSON_Error = PyErr_NewException("cjson.Error", NULL, NULL); + if (JSON_Error == NULL) +- return; ++ INITERROR; + Py_INCREF(JSON_Error); + PyModule_AddObject(m, "Error", JSON_Error); + + JSON_EncodeError = PyErr_NewException("cjson.EncodeError", JSON_Error, NULL); + if (JSON_EncodeError == NULL) +- return; ++ INITERROR; + Py_INCREF(JSON_EncodeError); + PyModule_AddObject(m, "EncodeError", JSON_EncodeError); + + JSON_DecodeError = PyErr_NewException("cjson.DecodeError", JSON_Error, NULL); + if (JSON_DecodeError == NULL) +- return; ++ INITERROR; + Py_INCREF(JSON_DecodeError); + PyModule_AddObject(m, "DecodeError", JSON_DecodeError); + + // Module version (the MODULE_VERSION macro is defined by setup.py) + PyModule_AddStringConstant(m, "__version__", string(MODULE_VERSION)); + ++#if PY_MAJOR_VERSION >= 3 ++ return m; ++#endif + } +- +- +diff --git a/jsontest.py b/jsontest.py +index 0f79307..19c24fa 100644 +--- a/jsontest.py ++++ b/jsontest.py +@@ -128,7 +128,7 @@ def testReadBadEscapedHexCharacter(self): + self.assertRaises(_exception, self.doReadBadEscapedHexCharacter) + + def doReadBadEscapedHexCharacter(self): +- cjson.decode('"\u10K5"') ++ cjson.decode(u'"\\u10K5"') + + def testReadBadObjectKey(self): + self.assertRaises(_exception, self.doReadBadObjectKey) +@@ -141,7 +141,7 @@ def testReadBadArray(self): + + def doReadBadArray(self): + cjson.decode('[1,2,3,,]') +- ++ + def testReadBadObjectSyntax(self): + self.assertRaises(_exception, self.doReadBadObjectSyntax) + +@@ -159,7 +159,7 @@ def testReadIntegerValue(self): + def testReadNegativeIntegerValue(self): + obj = cjson.decode('{ "key" : -44 }') + self.assertEqual({ "key" : -44 }, obj) +- ++ + def testReadFloatValue(self): + obj = cjson.decode('{ "age" : 44.5 }') + self.assertEqual({ "age" : 44.5 }, obj) +@@ -176,7 +176,7 @@ def doReadBadNumber(self): + + def testReadSmallObject(self): + obj = cjson.decode('{ "name" : "Patrick", "age":44} ') +- self.assertEqual({ "age" : 44, "name" : "Patrick" }, obj) ++ self.assertEqual({ "age" : 44, "name" : "Patrick" }, obj) + + def testReadEmptyArray(self): + obj = cjson.decode('[]') +@@ -194,7 +194,7 @@ def testWriteSmallArray(self): + + def testWriteSmallObject(self): + s = cjson.encode({ "name" : "Patrick", "age": 44 }) +- self.assertEqual('{"age":44,"name":"Patrick"}', _removeWhitespace(s)) ++ self.assertEqual('{"name":"Patrick","age":44}', _removeWhitespace(s)) + + def testWriteFloat(self): + n = 3.44556677 +@@ -276,7 +276,7 @@ def testWriteComplexArray(self): + obj = [{"name":"Patrick","age":44,"Employed?":True,"Female?":False,"grandchildren":None}, + "used","abused","confused", + 1,2,[3,4,5]] +- self.assertEqual('[{"Female?":false,"age":44,"name":"Patrick","grandchildren":null,"Employed?":true},"used","abused","confused",1,2,[3,4,5]]', ++ self.assertEqual('[{"name":"Patrick","age":44,"Employed?":true,"Female?":false,"grandchildren":null},"used","abused","confused",1,2,[3,4,5]]', + _removeWhitespace(cjson.encode(obj))) + + +@@ -290,7 +290,7 @@ def testReadWriteCopies(self): + + def testStringEncoding(self): + s = cjson.encode([1, 2, 3]) +- self.assertEqual(unicode("[1,2,3]", "utf-8"), _removeWhitespace(s)) ++ self.assertEqual("[1,2,3]", _removeWhitespace(s)) + + def testReadEmptyObjectAtEndOfArray(self): + self.assertEqual(["a","b","c",{}], +@@ -329,7 +329,7 @@ def testWriteLongUnicode(self): + u'\u1234\u1234\u1234\u1234\u1234\u1234') + self.assertEqual(r'"\U0001d11e\U0001d11e\U0001d11e\U0001d11e' + r'\u1234\u1234\u1234\u1234\u1234\u1234"', s) +- ++ + def main(): + unittest.main() + diff --git a/python-cjson-1.2.1.tar.gz b/python-cjson-1.2.1.tar.gz new file mode 100644 index 0000000..a6d6ddb --- /dev/null +++ b/python-cjson-1.2.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52db2745264624768bfd9b604acb38f631bde5c2ec9b23861677d747e4558626 +size 12575 diff --git a/python-python-cjson.changes b/python-python-cjson.changes new file mode 100644 index 0000000..eaa9af6 --- /dev/null +++ b/python-python-cjson.changes @@ -0,0 +1,57 @@ +------------------------------------------------------------------- +Sat May 11 02:13:29 UTC 2019 - John Vandenberg + +- Rename package from python-cjson to python-python-cjson +- Add Python 3 support using py3.patch +- Update to v1.2.1 + * Updated project homepage +- from v1.2.0 + * Implemented recursion limit check for encoding/decoding arrays and objects + * Updated copyright years and stripped licensing info from source code +- from v1.1.0 + * Use repr instead of str when encoding floats to preserve full preicision + * Fixed windows compilation problem introduced in 1.0.5 + * Fixed float write test to work with latest high precision float encoding + * Fixed some list/dict decoding bugs. Use a state machine for decoding them. + * Improved decoding speed by using PyString_GET_SIZE instead of strlen + * Integrate modified 0001-fix-for-CVE-2010-1666 patch from Debian + +------------------------------------------------------------------- +Sat Mar 7 22:30:23 CET 2009 - lars@linux-schulserver.de + +- build for openSUSE + +------------------------------------------------------------------- +Tue Oct 30 00:00:00 CET 2007 - James Oakley - 1.0.5-1 + +- Update to 1.0.5 + - Check if module initialization failed. + - Removed useless checks on module initialization. + - Added __version__ attribute to the cjson module. + - Call Py_INCREF before calling PyModule_AddObject. +- Changes in version 1.0.4 + - Added licensing information. + - Fixed issue with decrementing a string reference too early + (Edouard Hinard ). + - Fixed 64-bit portability problems (based on a modified version of a + patch by David Rushby ). + - Fixed issue with not returning NULL after setting the OverflowError + when encoded strings would be too big. + - Fixed 2 potential buffer overflow errors when encoding string/unicode + (thanks to Ofer Faigon for pointing them out). + - About 10% speed improvement when encoding/decoding string/unicode. + +------------------------------------------------------------------- +Fri Jul 13 00:00:00 CET 2007 - James Oakley - 1.0.3x6-1 + +- Update to 1.0.3x6 + - Fixed segmentation fault + + Fixed a rare, but reproducible segmentation fault when decoding specially + crafted unicode strings. Bug reported by: Liu Cougar - China + +------------------------------------------------------------------- +Sun Mar 04 00:00:00 CET 2007 - James Oakley - 1.0.3-1 + +- Initial release + diff --git a/python-python-cjson.spec b/python-python-cjson.spec new file mode 100644 index 0000000..d5440ba --- /dev/null +++ b/python-python-cjson.spec @@ -0,0 +1,85 @@ +# +# spec file for package python-python-cjson +# +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ + + +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +Name: python-python-cjson +Version: 1.2.1 +Release: 0 +License: LGPL-2.0-or-later +Summary: Fast JSON encoder/decoder for Python +Url: https://github.com/AGProjects/python-cjson +Group: Development/Languages/Python +Source: https://files.pythonhosted.org/packages/source/p/python-cjson/python-cjson-%{version}.tar.gz +# https://github.com/AGProjects/python-cjson/issues/6 +Patch0: py3.patch +BuildRequires: python-rpm-macros +BuildRequires: %{python_module devel} +BuildRequires: %{python_module setuptools} +BuildRequires: fdupes + +%python_subpackages + +%description +Fast JSON encoder/decoder for Python. + +JSON stands for JavaScript Object Notation and is a text based lightweight data +exchange format which is easy for humans to read/write and for machines to +parse/generate. JSON is completely language independent and has multiple +implementations in most of the programming languages, making it ideal for data +exchange and storage. + +The module is written in C and it is up to 250 times faster when compared to +the other python JSON implementations which are written directly in python. +This speed gain varies with the complexity of the data and the operation and is +the the range of 10-200 times for encoding operations and in the range of +100-250 times for decoding operations. + +%prep +%setup -q -n python-cjson-%{version} +cp cjson.c cjson%{python2_bin_suffix}.c +cp jsontest.py jsontest%{python2_bin_suffix}.py +%patch0 -p1 +cp cjson.c cjson%{python3_bin_suffix}.c + +cp jsontest.py jsontest%{python3_bin_suffix}.py +# Workaround dict order differences on Python 3.4 +if [ %{python3_bin_suffix} = '3.4' ]; then + sed -i 's/\(testWriteComplexArray\|testWriteSmallObject\)/_\1/' jsontest%{python3_bin_suffix}.py +fi + +%build +export CFLAGS="%{optflags} -fno-strict-aliasing" +rm cjson.c +ln -s cjson%{python2_bin_suffix}.c cjson.c +%python2_build +rm cjson.c +ln -s cjson%{python3_bin_suffix}.c cjson.c +%python3_build + +%install +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} + +%check +%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python jsontest%{$python_bin_suffix}.py + +%files %{python_files} +%doc ChangeLog README +%license LICENSE +%{python_sitearch}/* + +%changelog