File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use std::cell::Cell;
99// use.
1010#[ pyo3:: prelude:: pyclass( module = "cryptography.hazmat.bindings._rust" ) ]
1111pub ( crate ) struct FixedPool {
12- create_fn : pyo3:: PyObject ,
12+ create_fn : Option < pyo3:: PyObject > ,
1313
1414 value : Cell < Option < pyo3:: PyObject > > ,
1515}
@@ -29,7 +29,7 @@ impl FixedPool {
2929 let value = create. call0 ( py) ?;
3030
3131 Ok ( FixedPool {
32- create_fn : create,
32+ create_fn : Some ( create) ,
3333
3434 value : Cell :: new ( Some ( value) ) ,
3535 } )
@@ -44,14 +44,31 @@ impl FixedPool {
4444 fresh : false ,
4545 } )
4646 } else {
47- let value = slf. as_ref ( py) . borrow ( ) . create_fn . call0 ( py) ?;
47+ let value = slf
48+ . as_ref ( py)
49+ . borrow ( )
50+ . create_fn
51+ . as_ref ( )
52+ . unwrap ( )
53+ . call0 ( py) ?;
4854 Ok ( PoolAcquisition {
4955 pool : slf,
5056 value,
5157 fresh : true ,
5258 } )
5359 }
5460 }
61+
62+ fn __traverse__ ( & self , visit : pyo3:: PyVisit < ' _ > ) -> Result < ( ) , pyo3:: PyTraverseError > {
63+ if let Some ( create_fn) = & self . create_fn {
64+ visit. call ( create_fn) ?
65+ }
66+ Ok ( ( ) )
67+ }
68+
69+ fn __clear__ ( & mut self ) {
70+ self . create_fn = None ;
71+ }
5572}
5673
5774#[ pyo3:: pymethods]
You can’t perform that action at this time.
0 commit comments