@@ -7313,6 +7313,60 @@ def gen():
73137313 res = script_helper .assert_python_ok ('-c' , script )
73147314 self .assertFalse (res .err )
73157315
7316+ def test_static_type_at_shutdown3 (self ):
7317+ script = textwrap .dedent (f'''
7318+ import textwrap
7319+ from test import support
7320+
7321+ subinterp_script = textwrap.dedent(f"""
7322+ from _testcapi import get_delta_type
7323+ # Test without calling test_datetime_capi() in subinterp
7324+ timedelta = get_delta_type()
7325+
7326+ def gen():
7327+ try:
7328+ yield
7329+ finally:
7330+ timedelta(days=1)
7331+
7332+ it = gen()
7333+ next(it)
7334+ """)
7335+
7336+ import _testcapi
7337+ _testcapi.test_datetime_capi()
7338+ ret = support.run_in_subinterp(subinterp_script)
7339+ assert ret == 0
7340+ ''' )
7341+
7342+ res = script_helper .assert_python_ok ('-c' , script )
7343+ self .assertIn (b'ImportError: sys.meta_path is None' , res .err )
7344+
7345+ def test_static_type_before_shutdown (self ):
7346+ script = textwrap .dedent (f'''
7347+ import textwrap
7348+ from test import support
7349+
7350+ subinterp_script = textwrap.dedent(f"""
7351+ from _testcapi import get_delta_type
7352+ # Test without calling test_datetime_capi() in subinterp
7353+
7354+ import sys
7355+ assert '_datetime' not in sys.modules
7356+ timedelta = get_delta_type()
7357+ timedelta(days=1)
7358+ assert '_datetime' in sys.modules
7359+ """)
7360+
7361+ import _testcapi
7362+ _testcapi.test_datetime_capi()
7363+ ret = support.run_in_subinterp(subinterp_script)
7364+ assert ret == 0
7365+ ''' )
7366+
7367+ res = script_helper .assert_python_ok ('-c' , script )
7368+ self .assertFalse (res .err )
7369+
73167370 def test_remain_only_one_module (self ):
73177371 script = textwrap .dedent ("""
73187372 import sys
0 commit comments