|
1 | 1 | from test.test_json import PyTest, CTest |
2 | | -from test import support |
3 | | -import json |
4 | | -import sys |
5 | 2 |
|
6 | 3 | # 2007-10-05 |
7 | 4 | JSONDOCS = [ |
@@ -239,42 +236,5 @@ def test_linecol(self): |
239 | 236 | 'Expecting value: line %s column %d (char %d)' % |
240 | 237 | (line, col, idx)) |
241 | 238 |
|
242 | | - |
243 | | - def test_reentrant_jsondecodeerror_does_not_crash(self): |
244 | | - # gh-143544 |
245 | | - |
246 | | - class Trigger(ValueError): |
247 | | - def __call__(self, *args, **kwargs): |
248 | | - # Remove JSONDecodeError during construction to trigger re-entrancy |
249 | | - del json.JSONDecodeError |
250 | | - del json.decoder.JSONDecodeError |
251 | | - raise self |
252 | | - |
253 | | - hook = Trigger("boom") |
254 | | - |
255 | | - orig_json_error = json.JSONDecodeError |
256 | | - orig_decoder_error = json.decoder.JSONDecodeError |
257 | | - |
258 | | - try: |
259 | | - # NOTE: Do not use swap_attr() here. |
260 | | - # swap_attr() keeps the replacement object alive for the duration of |
261 | | - # the context manager, which prevents the crash this test is meant |
262 | | - # to reproduce |
263 | | - json.JSONDecodeError = hook |
264 | | - json.decoder.JSONDecodeError = hook |
265 | | - |
266 | | - # The hook must be kept alive by these references. |
267 | | - # Deleting it triggers the re-entrant path this test is exercising. |
268 | | - self.assertEqual(sys.getrefcount(hook), 3) |
269 | | - del hook |
270 | | - |
271 | | - support.gc_collect() |
272 | | - |
273 | | - with self.assertRaises(ValueError): |
274 | | - json.loads('"\\uZZZZ"') |
275 | | - finally: |
276 | | - json.JSONDecodeError = orig_json_error |
277 | | - json.decoder.JSONDecodeError = orig_decoder_error |
278 | | - |
279 | 239 | class TestPyFail(TestFail, PyTest): pass |
280 | 240 | class TestCFail(TestFail, CTest): pass |
0 commit comments