@@ -241,7 +241,12 @@ stacklet__callback(stacklet_handle h, void *arg)
241
241
self -> ts .exc_state .exc_type = NULL ;
242
242
self -> ts .exc_state .exc_traceback = NULL ;
243
243
#else
244
+ #if PY_MINOR_VERSION < 12
244
245
self -> ts .recursion_depth = tstate -> recursion_limit - tstate -> recursion_remaining ;
246
+ #else
247
+ self -> ts .recursion_depth = tstate -> py_recursion_limit - tstate -> py_recursion_remaining ;
248
+ self -> ts .c_recursion_remaining = tstate -> c_recursion_remaining ;
249
+ #endif
245
250
self -> ts .cframe = NULL ;
246
251
self -> ts .datastack_chunk = NULL ;
247
252
self -> ts .datastack_top = NULL ;
@@ -307,7 +312,12 @@ do_switch(Fiber *self, PyObject *value)
307
312
current -> ts .exc_state .exc_type = tstate -> exc_state .exc_type ;
308
313
current -> ts .exc_state .exc_traceback = tstate -> exc_state .exc_traceback ;
309
314
#else
315
+ #if PY_MINOR_VERSION < 12
310
316
current -> ts .recursion_depth = tstate -> recursion_limit - tstate -> recursion_remaining ;
317
+ #else
318
+ current -> ts .recursion_depth = tstate -> py_recursion_limit - tstate -> py_recursion_remaining ;
319
+ current -> ts .c_recursion_remaining = tstate -> c_recursion_remaining ;
320
+ #endif
311
321
current -> ts .frame = PyThreadState_GetFrame (tstate );
312
322
Py_XDECREF (current -> ts .frame );
313
323
current -> ts .cframe = tstate -> cframe ;
@@ -360,7 +370,12 @@ do_switch(Fiber *self, PyObject *value)
360
370
tstate -> exc_state .exc_type = current -> ts .exc_state .exc_type ;
361
371
tstate -> exc_state .exc_traceback = current -> ts .exc_state .exc_traceback ;
362
372
#else
373
+ #if PY_MINOR_VERSION < 12
363
374
tstate -> recursion_remaining = tstate -> recursion_limit - current -> ts .recursion_depth ;
375
+ #else
376
+ tstate -> py_recursion_remaining = tstate -> py_recursion_limit - current -> ts .recursion_depth ;
377
+ tstate -> c_recursion_remaining = current -> ts .c_recursion_remaining ;
378
+ #endif
364
379
tstate -> cframe = current -> ts .cframe ;
365
380
tstate -> datastack_chunk = current -> ts .datastack_chunk ;
366
381
tstate -> datastack_top = current -> ts .datastack_top ;
0 commit comments