Skip to content

Commit 4257cdc

Browse files
test_json: document and assert refcount for reentrant JSONDecodeError test
1 parent 0a03442 commit 4257cdc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/test/test_json/test_fail.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from test.test_json import PyTest, CTest
22
import json
3+
import sys
34

45
# 2007-10-05
56
JSONDOCS = [
@@ -260,6 +261,10 @@ def __call__(self, *args, **kwargs):
260261
# to reproduce
261262
json.JSONDecodeError = hook
262263
json.decoder.JSONDecodeError = hook
264+
265+
# The hook must be kept alive by these references.
266+
# Deleting it triggers the re-entrant path this test is exercising.
267+
self.assertEqual(sys.getrefcount(hook), 3)
263268
del hook
264269

265270
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)