@@ -93,6 +93,21 @@ class C:
93
93
new_version = type_get_version (C )
94
94
self .assertEqual (new_version , 0 )
95
95
96
+ def test_119462 (self ):
97
+
98
+ class Holder :
99
+ value = None
100
+
101
+ @classmethod
102
+ def set_value (cls ):
103
+ cls .value = object ()
104
+
105
+ class HolderSub (Holder ):
106
+ pass
107
+
108
+ for _ in range (1050 ):
109
+ Holder .set_value ()
110
+ HolderSub .value
96
111
97
112
@support .cpython_only
98
113
@requires_specialization
@@ -106,8 +121,10 @@ def _assign_valid_version_or_skip(self, type_):
106
121
if type_get_version (type_ ) == 0 :
107
122
self .skipTest ("Could not assign valid type version" )
108
123
109
- def _assign_and_check_version_0 (self , user_type ):
124
+ def _no_more_versions (self , user_type ):
110
125
type_modified (user_type )
126
+ for _ in range (1001 ):
127
+ type_assign_specific_version_unsafe (user_type , 1000_000_000 )
111
128
type_assign_specific_version_unsafe (user_type , 0 )
112
129
self .assertEqual (type_get_version (user_type ), 0 )
113
130
@@ -136,7 +153,7 @@ def load_foo_1(type_):
136
153
self ._check_specialization (load_foo_1 , A , "LOAD_ATTR" , should_specialize = True )
137
154
del load_foo_1
138
155
139
- self ._assign_and_check_version_0 (A )
156
+ self ._no_more_versions (A )
140
157
141
158
def load_foo_2 (type_ ):
142
159
return type_ .foo
@@ -187,7 +204,7 @@ def load_x_1(instance):
187
204
self ._check_specialization (load_x_1 , G (), "LOAD_ATTR" , should_specialize = True )
188
205
del load_x_1
189
206
190
- self ._assign_and_check_version_0 (G )
207
+ self ._no_more_versions (G )
191
208
192
209
def load_x_2 (instance ):
193
210
instance .x
@@ -206,7 +223,7 @@ def store_bar_1(type_):
206
223
self ._check_specialization (store_bar_1 , B (), "STORE_ATTR" , should_specialize = True )
207
224
del store_bar_1
208
225
209
- self ._assign_and_check_version_0 (B )
226
+ self ._no_more_versions (B )
210
227
211
228
def store_bar_2 (type_ ):
212
229
type_ .bar = 10
@@ -226,7 +243,7 @@ def call_class_1(type_):
226
243
self ._check_specialization (call_class_1 , F , "CALL" , should_specialize = True )
227
244
del call_class_1
228
245
229
- self ._assign_and_check_version_0 (F )
246
+ self ._no_more_versions (F )
230
247
231
248
def call_class_2 (type_ ):
232
249
type_ ()
@@ -245,7 +262,7 @@ def to_bool_1(instance):
245
262
self ._check_specialization (to_bool_1 , H (), "TO_BOOL" , should_specialize = True )
246
263
del to_bool_1
247
264
248
- self ._assign_and_check_version_0 (H )
265
+ self ._no_more_versions (H )
249
266
250
267
def to_bool_2 (instance ):
251
268
not instance
0 commit comments