@@ -9,8 +9,10 @@ mod inner {
99 #[ allow( unused_imports) ] // pulls in `use crate as pyo3` in `test_utils.rs`
1010 use super :: * ;
1111
12+ #[ cfg( not( Py_GIL_DISABLED ) ) ]
1213 use pyo3:: prelude:: * ;
1314
15+ #[ cfg( not( Py_GIL_DISABLED ) ) ]
1416 use pyo3:: types:: { IntoPyDict , PyList } ;
1517
1618 #[ macro_export]
@@ -63,14 +65,14 @@ mod inner {
6365 }
6466
6567 // sys.unraisablehook not available until Python 3.8
66- #[ cfg( all( feature = "macros" , Py_3_8 ) ) ]
68+ #[ cfg( all( feature = "macros" , Py_3_8 , not ( Py_GIL_DISABLED ) ) ) ]
6769 #[ pyclass( crate = "pyo3" ) ]
6870 pub struct UnraisableCapture {
6971 pub capture : Option < ( PyErr , PyObject ) > ,
7072 old_hook : Option < PyObject > ,
7173 }
7274
73- #[ cfg( all( feature = "macros" , Py_3_8 ) ) ]
75+ #[ cfg( all( feature = "macros" , Py_3_8 , not ( Py_GIL_DISABLED ) ) ) ]
7476 #[ pymethods( crate = "pyo3" ) ]
7577 impl UnraisableCapture {
7678 pub fn hook ( & mut self , unraisable : Bound < ' _ , PyAny > ) {
@@ -80,7 +82,7 @@ mod inner {
8082 }
8183 }
8284
83- #[ cfg( all( feature = "macros" , Py_3_8 ) ) ]
85+ #[ cfg( all( feature = "macros" , Py_3_8 , not ( Py_GIL_DISABLED ) ) ) ]
8486 impl UnraisableCapture {
8587 pub fn install ( py : Python < ' _ > ) -> Py < Self > {
8688 let sys = py. import ( "sys" ) . unwrap ( ) ;
@@ -109,10 +111,12 @@ mod inner {
109111 }
110112 }
111113
114+ #[ cfg( not( Py_GIL_DISABLED ) ) ]
112115 pub struct CatchWarnings < ' py > {
113116 catch_warnings : Bound < ' py , PyAny > ,
114117 }
115118
119+ #[ cfg( not( Py_GIL_DISABLED ) ) ]
116120 impl < ' py > CatchWarnings < ' py > {
117121 pub fn enter < R > (
118122 py : Python < ' py > ,
@@ -129,6 +133,7 @@ mod inner {
129133 }
130134 }
131135
136+ #[ cfg( not( Py_GIL_DISABLED ) ) ]
132137 impl Drop for CatchWarnings < ' _ > {
133138 fn drop ( & mut self ) {
134139 let py = self . catch_warnings . py ( ) ;
@@ -138,6 +143,7 @@ mod inner {
138143 }
139144 }
140145
146+ #[ cfg( not( Py_GIL_DISABLED ) ) ]
141147 #[ macro_export]
142148 macro_rules! assert_warnings {
143149 ( $py: expr, $body: expr, [ $( ( $category: ty, $message: literal) ) ,+] $( , ) ? ) => { {
0 commit comments