Skip to content

Commit 596007c

Browse files
committed
Add a failure test (crash)
1 parent 419500e commit 596007c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Lib/test/datetimetester.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7301,6 +7301,26 @@ def test_update_type_cache(self):
73017301
res = script_helper.assert_python_ok('-c', script)
73027302
self.assertFalse(res.err)
73037303

7304+
def test_static_type_attr_on_subinterp(self):
7305+
script = textwrap.dedent(f"""
7306+
date = _testcapi.get_capi_types()['date']
7307+
date.today
7308+
""")
7309+
# Fail before loaded
7310+
with self.subTest('[PyDateTime_IMPORT] main: yes sub: no'):
7311+
res = CapiTest.assert_python_in_subinterp(self, False, script)
7312+
self.assertIn(b'_PyType_CheckConsistency: Assertion failed', res.err)
7313+
self.assertIn(b'lookup_tp_dict(type) != ((void *)0)', res.err)
7314+
7315+
# OK after loaded
7316+
with self.subTest('[PyDateTime_IMPORT] main: no sub: yes'):
7317+
script2 = f'_testcapi.test_datetime_capi()\n{script}'
7318+
CapiTest.assert_python_in_subinterp(self, True, script2)
7319+
7320+
with self.subTest('Regular'):
7321+
script2 = f'import _datetime\n{script}'
7322+
CapiTest.assert_python_in_subinterp(self, True, script2)
7323+
73047324
def test_static_type_at_shutdown1(self):
73057325
# gh-132413
73067326
script = textwrap.dedent("""

0 commit comments

Comments
 (0)