@@ -33,9 +33,10 @@ fn create_exception_group(ctx: &Context) -> PyRef<PyType> {
3333}
3434
3535pub fn exception_group ( ) -> & ' static Py < PyType > {
36- static EXCEPTION_GROUP : std:: sync:: LazyLock < PyTypeRef > =
37- std:: sync:: LazyLock :: new ( || create_exception_group ( Context :: genesis ( ) ) ) ;
38- EXCEPTION_GROUP . as_ref ( )
36+ :: rustpython_vm:: common:: static_cell! {
37+ static CELL : :: rustpython_vm:: builtins:: PyTypeRef ;
38+ }
39+ CELL . get_or_init ( || create_exception_group ( Context :: genesis ( ) ) )
3940}
4041
4142pub ( super ) mod types {
@@ -253,7 +254,7 @@ pub(super) mod types {
253254 let result = vm. call_method ( & exc, "split" , ( condition. clone ( ) , ) ) ?;
254255 let result_tuple: PyTupleRef = result. try_into_value ( vm) ?;
255256 let match_part = result_tuple
256- . get ( 0 )
257+ . first ( )
257258 . cloned ( )
258259 . unwrap_or_else ( || vm. ctx . none ( ) ) ;
259260 let rest_part = result_tuple
@@ -378,10 +379,10 @@ pub(super) mod types {
378379 vm : & VirtualMachine ,
379380 ) -> PyResult < ConditionMatcher > {
380381 // If it's a type and subclass of BaseException
381- if let Some ( typ) = condition. downcast_ref :: < PyType > ( ) {
382- if typ. fast_issubclass ( vm. ctx . exceptions . base_exception_type ) {
383- return Ok ( ConditionMatcher :: Type ( typ . to_owned ( ) ) ) ;
384- }
382+ if let Some ( typ) = condition. downcast_ref :: < PyType > ( )
383+ && typ. fast_issubclass ( vm. ctx . exceptions . base_exception_type )
384+ {
385+ return Ok ( ConditionMatcher :: Type ( typ . to_owned ( ) ) ) ;
385386 }
386387
387388 // If it's a tuple of types
@@ -456,11 +457,11 @@ pub(super) mod types {
456457 }
457458
458459 // Copy notes (if present) - make a copy of the list
459- if let Ok ( notes) = orig. as_object ( ) . get_attr ( "__notes__" , vm) {
460- if let Some ( notes_list) = notes. downcast_ref :: < PyList > ( ) {
461- let notes_copy = vm . ctx . new_list ( notes_list . borrow_vec ( ) . to_vec ( ) ) ;
462- new_group . set_attr ( "__notes__" , notes_copy , vm ) ? ;
463- }
460+ if let Ok ( notes) = orig. as_object ( ) . get_attr ( "__notes__" , vm)
461+ && let Some ( notes_list) = notes. downcast_ref :: < PyList > ( )
462+ {
463+ let notes_copy = vm . ctx . new_list ( notes_list . borrow_vec ( ) . to_vec ( ) ) ;
464+ new_group . set_attr ( "__notes__" , notes_copy , vm ) ? ;
464465 }
465466
466467 Ok ( new_group)
0 commit comments