1
0
Fork 0
mirror of https://github.com/ultrajson/ultrajson.git synced 2024-05-06 21:16:19 +02:00

Merge pull request #439 from mbish/master

Fix dealing with None types
This commit is contained in:
Hugo van Kemenade 2020-11-06 22:58:51 +02:00 committed by GitHub
commit f26f9679f1
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -258,7 +258,9 @@ static int Dict_iterNext(JSOBJ obj, JSONTypeContext *tc)
{
if (UNLIKELY(GET_TC(tc)->itemName == Py_None))
{
GET_TC(tc)->itemName = PyUnicode_FromString("null");
itemNameTmp = PyUnicode_FromString("null");
GET_TC(tc)->itemName = PyUnicode_AsUTF8String(itemNameTmp);
Py_DECREF(Py_None);
return 1;
}
@ -537,19 +539,19 @@ static void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc, JSONObject
return;
}
else
if (PyFloat_Check(obj) || object_is_decimal_type(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyFloatToDOUBLE; tc->type = JT_DOUBLE;
return;
}
else
if (obj == Py_None)
{
PRINTMARK();
tc->type = JT_NULL;
return;
}
else
if (PyFloat_Check(obj) || object_is_decimal_type(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyFloatToDOUBLE; tc->type = JT_DOUBLE;
return;
}
ISITERABLE:

View File

@ -806,6 +806,11 @@ def test_reject_bytes_false():
assert ujson.dumps(data, reject_bytes=False) == '{"a":"b"}'
def test_encode_none_key():
data = {None: None}
assert ujson.dumps(data) == '{"null":null}'
"""
def test_decode_numeric_int_frc_overflow():
input = "X.Y"