@@ -717,13 +717,10 @@ def write(items):
717717 @requires_specialization_ft
718718 def test_load_attr_class (self ):
719719 def get_items ():
720- class B :
721- pass
722-
723720 class C :
724721 # a must be set to an instance that uses deferred reference
725- # counting
726- a = B
722+ # counting in free-threaded builds
723+ a = type ( "Foo" , ( object ,), {})
727724
728725 items = []
729726 for _ in range (self .ITEMS ):
@@ -744,11 +741,46 @@ def write(items):
744741 del item .a
745742 except AttributeError :
746743 pass
747- item .a = object ( )
744+ item .a = type ( "Foo" , ( object ,), {} )
748745
749746 opname = "LOAD_ATTR_CLASS"
750747 self .assert_races_do_not_crash (opname , get_items , read , write )
751748
749+ @requires_specialization_ft
750+ def test_load_attr_class_with_metaclass_check (self ):
751+ def get_items ():
752+ class Meta (type ):
753+ pass
754+
755+ class C (metaclass = Meta ):
756+ # a must be set to an instance that uses deferred reference
757+ # counting in free-threaded builds
758+ a = type ("Foo" , (object ,), {})
759+
760+ items = []
761+ for _ in range (self .ITEMS ):
762+ item = C
763+ items .append (item )
764+ return items
765+
766+ def read (items ):
767+ for item in items :
768+ try :
769+ item .a
770+ except AttributeError :
771+ pass
772+
773+ def write (items ):
774+ for item in items :
775+ try :
776+ del item .a
777+ except AttributeError :
778+ pass
779+ item .a = type ("Foo" , (object ,), {})
780+
781+ opname = "LOAD_ATTR_CLASS_WITH_METACLASS_CHECK"
782+ self .assert_races_do_not_crash (opname , get_items , read , write )
783+
752784 @requires_specialization_ft
753785 def test_load_attr_getattribute_overridden (self ):
754786 def get_items ():
0 commit comments