@@ -2460,28 +2460,6 @@ check_threadstate_set_stack_protection(PyThreadState *tstate,
24602460 assert (ts -> c_stack_soft_limit < ts -> c_stack_top );
24612461}
24622462
2463- #define NUM_GUARDS 100
2464-
2465- static PyObject *
2466- test_interp_guard_countdown (PyObject * self , PyObject * unused )
2467- {
2468- PyInterpreterState * interp = PyInterpreterState_Get ();
2469- assert (_PyInterpreterState_LockCountdown (interp ) == 0 );
2470- PyInterpreterGuard guards [NUM_GUARDS ];
2471- for (int i = 0 ; i < NUM_GUARDS ; ++ i ) {
2472- guards [i ] = PyInterpreterGuard_FromCurrent ();
2473- assert (guards [i ] != 0 );
2474- assert (_PyInterpreterState_LockCountdown (interp ) == i + 1 );
2475- }
2476-
2477- for (int i = 0 ; i < NUM_GUARDS ; ++ i ) {
2478- PyInterpreterGuard_Release (guards [i ]);
2479- assert (_PyInterpreterState_LockCountdown (interp ) == (NUM_GUARDS - i - 1 ));
2480- }
2481-
2482- Py_RETURN_NONE ;
2483- }
2484-
24852463
24862464static PyObject *
24872465test_threadstate_set_stack_protection (PyObject * self , PyObject * Py_UNUSED (args ))
@@ -2519,6 +2497,28 @@ test_threadstate_set_stack_protection(PyObject *self, PyObject *Py_UNUSED(args))
25192497 Py_RETURN_NONE ;
25202498}
25212499
2500+ #define NUM_GUARDS 100
2501+
2502+ static PyObject *
2503+ test_interp_guard_countdown (PyObject * self , PyObject * unused )
2504+ {
2505+ PyInterpreterState * interp = PyInterpreterState_Get ();
2506+ assert (_PyInterpreterState_GuardCountdown (interp ) == 0 );
2507+ PyInterpreterGuard guards [NUM_GUARDS ];
2508+ for (int i = 0 ; i < NUM_GUARDS ; ++ i ) {
2509+ guards [i ] = PyInterpreterGuard_FromCurrent ();
2510+ assert (guards [i ] != 0 );
2511+ assert (_PyInterpreterState_GuardCountdown (interp ) == i + 1 );
2512+ }
2513+
2514+ for (int i = 0 ; i < NUM_GUARDS ; ++ i ) {
2515+ PyInterpreterGuard_Release (guards [i ]);
2516+ assert (_PyInterpreterState_GuardCountdown (interp ) == (NUM_GUARDS - i - 1 ));
2517+ }
2518+
2519+ Py_RETURN_NONE ;
2520+ }
2521+
25222522static PyObject *
25232523test_interp_view_countdown (PyObject * self , PyObject * unused )
25242524{
@@ -2527,20 +2527,20 @@ test_interp_view_countdown(PyObject *self, PyObject *unused)
25272527 if (view == 0 ) {
25282528 return NULL ;
25292529 }
2530- assert (_PyInterpreterState_LockCountdown (interp ) == 0 );
2530+ assert (_PyInterpreterState_GuardCountdown (interp ) == 0 );
25312531
25322532 PyInterpreterGuard guards [NUM_GUARDS ];
25332533
25342534 for (int i = 0 ; i < NUM_GUARDS ; ++ i ) {
25352535 guards [i ] = PyInterpreterGuard_FromView (view );
25362536 assert (guards [i ] != 0 );
25372537 assert (PyInterpreterGuard_GetInterpreter (guards [i ]) == interp );
2538- assert (_PyInterpreterState_LockCountdown (interp ) == i + 1 );
2538+ assert (_PyInterpreterState_GuardCountdown (interp ) == i + 1 );
25392539 }
25402540
25412541 for (int i = 0 ; i < NUM_GUARDS ; ++ i ) {
25422542 PyInterpreterGuard_Release (guards [i ]);
2543- assert (_PyInterpreterState_LockCountdown (interp ) == (NUM_GUARDS - i - 1 ));
2543+ assert (_PyInterpreterState_GuardCountdown (interp ) == (NUM_GUARDS - i - 1 ));
25442544 }
25452545
25462546 PyInterpreterView_Close (view );
0 commit comments