From d74b908ff2c87eba57bb2de5495ddd310a96b2c1 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Tue, 10 Dec 2024 14:58:56 -0700 Subject: [PATCH] fix build error on GIL-enabled build --- src/types/dict.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/types/dict.rs b/src/types/dict.rs index 83a6dc6b836..b691ed0efc7 100644 --- a/src/types/dict.rs +++ b/src/types/dict.rs @@ -512,10 +512,17 @@ impl<'py> Iterator for BoundDictIterator<'py> { #[inline] fn next(&mut self) -> Option { - self.inner - .with_critical_section(&self.dict, |inner| unsafe { - inner.next_unchecked(&self.dict) - }) + #[cfg(Py_GIL_DISABLED)] + { + self.inner + .with_critical_section(&self.dict, |inner| unsafe { + inner.next_unchecked(&self.dict) + }) + } + #[cfg(not(Py_GIL_DISABLED))] + { + unsafe { self.inner.next_unchecked(&self.dict) } + } } #[inline]