@@ -22,13 +22,13 @@ const UUID_IS_SAFE: &str = "is_safe";
22
22
static UUID_TYPE : GILOnceCell < Py < PyType > > = GILOnceCell :: new ( ) ;
23
23
24
24
fn import_type ( py : Python , module : & str , attr : & str ) -> PyResult < Py < PyType > > {
25
- py. import ( module) ?. getattr ( attr) ?. extract ( )
25
+ py. import2 ( module) ?. getattr ( attr) ?. extract ( )
26
26
}
27
27
28
- fn get_uuid_type ( py : Python ) -> PyResult < & PyType > {
28
+ fn get_uuid_type ( py : Python ) -> PyResult < & Py2 < ' _ , PyType > > {
29
29
Ok ( UUID_TYPE
30
30
. get_or_init ( py, || import_type ( py, "uuid" , "UUID" ) . unwrap ( ) )
31
- . as_ref ( py) )
31
+ . attach ( py) )
32
32
}
33
33
34
34
#[ derive( Debug , Clone , Copy ) ]
@@ -92,7 +92,7 @@ impl Validator for UuidValidator {
92
92
state : & mut ValidationState ,
93
93
) -> ValResult < PyObject > {
94
94
let class = get_uuid_type ( py) ?;
95
- if let Some ( py_input) = input. input_is_instance ( class) {
95
+ if let Some ( py_input) = input. input_is_instance ( class. as_gil_ref ( ) ) {
96
96
if let Some ( expected_version) = self . version {
97
97
let py_input_version: Option < usize > = py_input. getattr ( intern ! ( py, "version" ) ) ?. extract ( ) ?;
98
98
if !match py_input_version {
@@ -125,7 +125,7 @@ impl Validator for UuidValidator {
125
125
state. floor_exactness ( Exactness :: Lax ) ;
126
126
}
127
127
let uuid = self . get_uuid ( input) ?;
128
- self . create_py_uuid ( py , class, & uuid)
128
+ self . create_py_uuid ( class, & uuid)
129
129
}
130
130
}
131
131
@@ -198,8 +198,9 @@ impl UuidValidator {
198
198
///
199
199
/// This implementation does not use the Python `__init__` function to speed up the process,
200
200
/// as the `__init__` function in the Python `uuid` module performs extensive checks.
201
- fn create_py_uuid ( & self , py : Python < ' _ > , py_type : & PyType , uuid : & Uuid ) -> ValResult < Py < PyAny > > {
202
- let class = create_class ( py_type) ?;
201
+ fn create_py_uuid ( & self , py_type : & Py2 < ' _ , PyType > , uuid : & Uuid ) -> ValResult < Py < PyAny > > {
202
+ let py = py_type. py ( ) ;
203
+ let class = create_class ( py_type. as_gil_ref ( ) ) ?;
203
204
let dc = class. as_ref ( py) ;
204
205
let int = uuid. as_u128 ( ) ;
205
206
let safe = py
0 commit comments