Skip to content

Commit 211cb30

Browse files
test_json: fix re-entrant JSONDecodeError test
1 parent 74cfaed commit 211cb30

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/test/test_json/test_fail.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,14 @@ def test_linecol(self):
243243
def test_reentrant_jsondecodeerror_does_not_crash(self):
244244
# gh-143544
245245

246-
class Trigger:
246+
class Trigger(ValueError):
247247
def __call__(self, *args, **kwargs):
248248
# Remove JSONDecodeError during construction to trigger re-entrancy
249249
del json.JSONDecodeError
250250
del json.decoder.JSONDecodeError
251-
return ValueError("boom")
251+
raise self
252252

253-
hook = Trigger()
253+
hook = Trigger("boom")
254254

255255
orig_json_error = json.JSONDecodeError
256256
orig_decoder_error = json.decoder.JSONDecodeError
@@ -269,8 +269,8 @@ def __call__(self, *args, **kwargs):
269269
del hook
270270

271271
support.gc_collect()
272-
273-
with self.assertRaises(TypeError):
272+
273+
with self.assertRaises(ValueError):
274274
json.loads('"\\uZZZZ"')
275275
finally:
276276
json.JSONDecodeError = orig_json_error

0 commit comments

Comments
 (0)