Used to run the body of a (possibly) recursive function. It will raise a RecursionError if recursive functions are nested far too many times, preventing a stack overflow.
(&self, _where: &str, f: F)
| 1537 | /// RecursionError if recursive functions are nested far too many times, |
| 1538 | /// preventing a stack overflow. |
| 1539 | pub fn with_recursion<R, F: FnOnce() -> PyResult<R>>(&self, _where: &str, f: F) -> PyResult<R> { |
| 1540 | self.check_recursive_call(_where)?; |
| 1541 | |
| 1542 | // Native stack guard: check C stack like _Py_MakeRecCheck |
| 1543 | if self.check_c_stack_overflow() { |
| 1544 | return Err(self.new_recursion_error(_where.to_string())); |
| 1545 | } |
| 1546 | |
| 1547 | self.recursion_depth.update(|d| d + 1); |
| 1548 | scopeguard::defer! { self.recursion_depth.update(|d| d - 1) } |
| 1549 | f() |
| 1550 | } |
| 1551 | |
| 1552 | pub fn with_frame<R, F: FnOnce(FrameRef) -> PyResult<R>>( |
| 1553 | &self, |
no test coverage detected