diff --git a/django/tasks/utils.py b/django/tasks/utils.py index c527ea2972..62bf928127 100644 --- a/django/tasks/utils.py +++ b/django/tasks/utils.py @@ -1,7 +1,6 @@ import inspect import json import time -from collections import deque from functools import wraps from traceback import format_exception @@ -18,18 +17,6 @@ def is_global_function(func): return True -def is_json_serializable(obj): - """ - Determine, as efficiently as possible, whether an object is JSON-serializable. - """ - try: - # HACK: JSON-encode an object, without loading it all into memory - deque(json.JSONEncoder().iterencode(obj), maxlen=0) - return True - except (TypeError, OverflowError): - return False - - def json_normalize(obj): """ Round-trip encode object as JSON to normalize types. diff --git a/tests/tasks/test_utils.py b/tests/tasks/test_utils.py index c22e21ec20..47a8bb5ce2 100644 --- a/tests/tasks/test_utils.py +++ b/tests/tasks/test_utils.py @@ -48,22 +48,6 @@ class IsGlobalFunctionTestCase(SimpleTestCase): self.assertFalse(is_global_function_fixture.inner_func_is_global_function) -class IsJSONSerializableTestCase(SimpleTestCase): - def test_serializable(self): - for example in [123, 12.3, "123", {"123": 456}, [], None]: - with self.subTest(example): - self.assertTrue(utils.is_json_serializable(example)) - - def test_not_serializable(self): - for example in [ - self, - any, - datetime.datetime.now(), - ]: - with self.subTest(example): - self.assertFalse(utils.is_json_serializable(example)) - - class JSONNormalizeTestCase(SimpleTestCase): def test_round_trip(self): self.assertEqual(utils.json_normalize({}), {})