{"repo": "Kinto/kinto", "pull_number": 2737, "instance_id": "Kinto__kinto-2737", "issue_numbers": "", "base_commit": "6102cf98e3246b44532432df61275858653d9323", "patch": "diff --git a/kinto/core/initialization.py b/kinto/core/initialization.py\n--- a/kinto/core/initialization.py\n+++ b/kinto/core/initialization.py\n@@ -47,11 +47,11 @@ def setup_json_serializer(config):\n import requests\n import webob\n \n- # Monkey patch to use ujson\n+ # Monkey patch to use rapidjson\n webob.request.json = utils.json\n requests.models.json = utils.json\n \n- # Override json renderer using ujson\n+ # Override json renderer using rapidjson\n renderer = JSONRenderer(serializer=utils.json_serializer)\n config.add_renderer(\"ultrajson\", renderer) # See `kinto.core.Service`\n \ndiff --git a/kinto/core/utils.py b/kinto/core/utils.py\n--- a/kinto/core/utils.py\n+++ b/kinto/core/utils.py\n@@ -11,7 +11,7 @@\n from urllib.parse import unquote\n \n import jsonpatch\n-import ujson as json\n+import rapidjson\n from colander import null\n from cornice import cors\n from pyramid import httpexceptions\n@@ -32,8 +32,21 @@\n memcache = None\n \n \n-def json_serializer(v, **kw):\n- return json.dumps(v, escape_forward_slashes=False)\n+class json:\n+ def dumps(v, **kw):\n+ kw.setdefault(\"bytes_mode\", rapidjson.BM_NONE)\n+ return rapidjson.dumps(v, **kw)\n+\n+ def load(v, **kw):\n+ kw.setdefault(\"number_mode\", rapidjson.NM_NATIVE)\n+ return rapidjson.load(v, **kw)\n+\n+ def loads(v, **kw):\n+ kw.setdefault(\"number_mode\", rapidjson.NM_NATIVE)\n+ return rapidjson.loads(v, **kw)\n+\n+\n+json_serializer = json.dumps\n \n \n def strip_whitespace(v):\ndiff --git a/kinto/plugins/quotas/utils.py b/kinto/plugins/quotas/utils.py\n--- a/kinto/plugins/quotas/utils.py\n+++ b/kinto/plugins/quotas/utils.py\n@@ -2,6 +2,6 @@\n \n \n def record_size(record):\n- # We cannot use ultrajson here, since the `separator` option is not available.\n+ # We cannot use rapidjson here, since the `separator` option is not available.\n canonical_json = json.dumps(record, sort_keys=True, separators=(\",\", \":\"))\n return len(canonical_json)\n", "test_patch": "diff --git a/tests/test_views_schema_record.py b/tests/test_views_schema_record.py\n--- a/tests/test_views_schema_record.py\n+++ b/tests/test_views_schema_record.py\n@@ -385,3 +385,27 @@ def setUp(self):\n \n def test_records_are_valid_if_match_schema(self):\n self.app.post_json(RECORDS_URL, {\"data\": {\"title\": \"b\"}}, headers=self.headers, status=400)\n+\n+\n+class RecordsWithLargeNumbers(BaseWebTestWithSchema, unittest.TestCase):\n+ def setUp(self):\n+ super().setUp()\n+ self.app.put_json(COLLECTION_URL, {\"data\": {\"schema\": SCHEMA}}, headers=self.headers)\n+\n+ def test_record_with_number_less_than_64_bits(self):\n+ size = 2 ** 63\n+ self.app.post_json(\n+ RECORDS_URL,\n+ {\"data\": {\"title\": \"Very large file\", \"file\": {\"size\": size}}},\n+ headers=self.headers,\n+ status=201,\n+ )\n+\n+ def test_record_with_number_greater_than_64_bits(self):\n+ size = 2 ** 65\n+ self.app.post_json(\n+ RECORDS_URL,\n+ {\"data\": {\"title\": \"Very large file\", \"file\": {\"size\": size}}},\n+ headers=self.headers,\n+ status=201,\n+ )\n", "problem_statement": "", "hints_text": "", "created_at": "2021-03-04T16:32:35Z"}