Skip to content

Commit 396edb1

Browse files
committed
Enable test_opcache tests
1 parent e1bf1f4 commit 396edb1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Lib/test/test_opcache.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def write(items):
752752
opname = "LOAD_ATTR_CLASS"
753753
self.assert_races_do_not_crash(opname, get_items, read, write)
754754

755-
@requires_specialization
755+
@requires_specialization_ft
756756
def test_load_attr_getattribute_overridden(self):
757757
def get_items():
758758
class C:
@@ -779,6 +779,7 @@ def write(items):
779779
pass
780780
type(item).__getattribute__ = lambda self, name: None
781781

782+
782783
opname = "LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN"
783784
self.assert_races_do_not_crash(opname, get_items, read, write)
784785

@@ -806,7 +807,7 @@ def write(items):
806807
opname = "LOAD_ATTR_INSTANCE_VALUE"
807808
self.assert_races_do_not_crash(opname, get_items, read, write)
808809

809-
@requires_specialization
810+
@requires_specialization_ft
810811
def test_load_attr_method_lazy_dict(self):
811812
def get_items():
812813
class C(Exception):
@@ -836,7 +837,7 @@ def write(items):
836837
opname = "LOAD_ATTR_METHOD_LAZY_DICT"
837838
self.assert_races_do_not_crash(opname, get_items, read, write)
838839

839-
@requires_specialization
840+
@requires_specialization_ft
840841
def test_load_attr_method_no_dict(self):
841842
def get_items():
842843
class C:
@@ -867,7 +868,7 @@ def write(items):
867868
opname = "LOAD_ATTR_METHOD_NO_DICT"
868869
self.assert_races_do_not_crash(opname, get_items, read, write)
869870

870-
@requires_specialization
871+
@requires_specialization_ft
871872
def test_load_attr_method_with_values(self):
872873
def get_items():
873874
class C:
@@ -922,7 +923,7 @@ def write(items):
922923
opname = "LOAD_ATTR_MODULE"
923924
self.assert_races_do_not_crash(opname, get_items, read, write)
924925

925-
@requires_specialization
926+
@requires_specialization_ft
926927
def test_load_attr_property(self):
927928
def get_items():
928929
class C:

Python/specialize.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,12 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
12201220
return -1;
12211221
case GETATTRIBUTE_IS_PYTHON_FUNCTION:
12221222
{
1223+
#ifndef Py_GIL_DISABLED
1224+
// In free-threaded builds it's possible for tp_getattro to change
1225+
// after the call to analyze_descriptor. That is fine: the version
1226+
// guard will fail.
12231227
assert(type->tp_getattro == _Py_slot_tp_getattro);
1228+
#endif
12241229
assert(Py_IS_TYPE(descr, &PyFunction_Type));
12251230
_PyLoadMethodCache *lm_cache = (_PyLoadMethodCache *)(instr + 1);
12261231
if (!function_check_args(descr, 2, LOAD_ATTR)) {

0 commit comments

Comments
 (0)