Skip to content

Commit 8651ebe

Browse files
committed
Enable tests
1 parent 8ebd73d commit 8651ebe

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

Lib/test/test_monitoring.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import unittest
1212

1313
import test.support
14-
from test.support import requires_specialization, script_helper
14+
from test.support import requires_specialization_ft, script_helper
1515
from test.support.import_helper import import_module
1616

1717
_testcapi = test.support.import_helper.import_module("_testcapi")
@@ -850,6 +850,13 @@ def __init__(self, events):
850850
def __call__(self, code, offset, val):
851851
self.events.append(("return", code.co_name, val))
852852

853+
# CALL_ALLOC_AND_ENTER_INIT will only cache __init__ methods that are
854+
# deferred. We only defer functions defined at the top-level.
855+
class ValueErrorRaiser:
856+
def __init__(self):
857+
raise ValueError()
858+
859+
853860
class ExceptionMonitoringTest(CheckEvents):
854861

855862
exception_recorders = (
@@ -1045,16 +1052,12 @@ def func():
10451052
)
10461053
self.assertEqual(events[0], ("throw", IndexError))
10471054

1048-
@requires_specialization
1055+
@requires_specialization_ft
10491056
def test_no_unwind_for_shim_frame(self):
10501057

1051-
class B:
1052-
def __init__(self):
1053-
raise ValueError()
1054-
10551058
def f():
10561059
try:
1057-
return B()
1060+
return ValueErrorRaiser()
10581061
except ValueError:
10591062
pass
10601063

Lib/test/test_opcache.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ def f():
493493
self.assertFalse(f())
494494

495495

496+
# CALL_ALLOC_AND_ENTER_INIT will only cache __init__ methods that are
497+
# deferred. We only defer functions defined at the top-level.
498+
class MyClass:
499+
def __init__(self):
500+
pass
501+
502+
496503
class TestCallCache(TestBase):
497504
def test_too_many_defaults_0(self):
498505
def f():
@@ -522,12 +529,8 @@ def f(x, y):
522529
f()
523530

524531
@disabling_optimizer
525-
@requires_specialization
532+
@requires_specialization_ft
526533
def test_assign_init_code(self):
527-
class MyClass:
528-
def __init__(self):
529-
pass
530-
531534
def instantiate():
532535
return MyClass()
533536

Lib/test/test_type_cache.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import unittest
33
import dis
44
from test import support
5-
from test.support import import_helper, requires_specialization
5+
from test.support import import_helper, requires_specialization, requires_specialization_ft
66
try:
77
from sys import _clear_type_cache
88
except ImportError:
@@ -110,7 +110,6 @@ class HolderSub(Holder):
110110
HolderSub.value
111111

112112
@support.cpython_only
113-
@requires_specialization
114113
class TypeCacheWithSpecializationTests(unittest.TestCase):
115114
def tearDown(self):
116115
_clear_type_cache()
@@ -140,6 +139,7 @@ def _check_specialization(self, func, arg, opname, *, should_specialize):
140139
else:
141140
self.assertIn(opname, self._all_opnames(func))
142141

142+
@requires_specialization
143143
def test_class_load_attr_specialization_user_type(self):
144144
class A:
145145
def foo(self):
@@ -160,6 +160,7 @@ def load_foo_2(type_):
160160

161161
self._check_specialization(load_foo_2, A, "LOAD_ATTR", should_specialize=False)
162162

163+
@requires_specialization
163164
def test_class_load_attr_specialization_static_type(self):
164165
self.assertNotEqual(type_get_version(str), 0)
165166
self.assertNotEqual(type_get_version(bytes), 0)
@@ -171,6 +172,7 @@ def get_capitalize_1(type_):
171172
self.assertEqual(get_capitalize_1(str)('hello'), 'Hello')
172173
self.assertEqual(get_capitalize_1(bytes)(b'hello'), b'Hello')
173174

175+
@requires_specialization
174176
def test_property_load_attr_specialization_user_type(self):
175177
class G:
176178
@property
@@ -192,6 +194,7 @@ def load_x_2(instance):
192194

193195
self._check_specialization(load_x_2, G(), "LOAD_ATTR", should_specialize=False)
194196

197+
@requires_specialization
195198
def test_store_attr_specialization_user_type(self):
196199
class B:
197200
__slots__ = ("bar",)
@@ -211,6 +214,7 @@ def store_bar_2(type_):
211214

212215
self._check_specialization(store_bar_2, B(), "STORE_ATTR", should_specialize=False)
213216

217+
@requires_specialization_ft
214218
def test_class_call_specialization_user_type(self):
215219
class F:
216220
def __init__(self):
@@ -231,6 +235,7 @@ def call_class_2(type_):
231235

232236
self._check_specialization(call_class_2, F, "CALL", should_specialize=False)
233237

238+
@requires_specialization
234239
def test_to_bool_specialization_user_type(self):
235240
class H:
236241
pass

0 commit comments

Comments
 (0)