Skip to content

Commit a2e23bc

Browse files
gh-143544: Revert test_json regression test changes
1 parent 211cb30 commit a2e23bc

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

Lib/test/test_json/test_fail.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
from test.test_json import PyTest, CTest
2-
from test import support
3-
import json
4-
import sys
52

63
# 2007-10-05
74
JSONDOCS = [
@@ -239,42 +236,5 @@ def test_linecol(self):
239236
'Expecting value: line %s column %d (char %d)' %
240237
(line, col, idx))
241238

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-
279239
class TestPyFail(TestFail, PyTest): pass
280240
class TestCFail(TestFail, CTest): pass

0 commit comments

Comments
 (0)