Skip to content

Commit 8dac8c4

Browse files
committed
Enable LOAD_ATTR_PROPERTY
- Check that fget is deferred - Pass tp_version
1 parent e7cea82 commit 8dac8c4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Python/specialize.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,6 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
11711171
}
11721172
case PROPERTY:
11731173
{
1174-
FT_UNIMPLEMENTED();
11751174
_PyLoadMethodCache *lm_cache = (_PyLoadMethodCache *)(instr + 1);
11761175
assert(Py_TYPE(descr) == &PyProperty_Type);
11771176
PyObject *fget = ((_PyPropertyObject *)descr)->prop_get;
@@ -1194,8 +1193,14 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
11941193
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OTHER);
11951194
return -1;
11961195
}
1197-
assert(type->tp_version_tag != 0);
1198-
write_u32(lm_cache->type_version, type->tp_version_tag);
1196+
#ifdef Py_GIL_DISABLED
1197+
if (!_PyObject_HasDeferredRefcount(fget)) {
1198+
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_DESCR_NOT_DEFERRED);
1199+
return -1;
1200+
}
1201+
#endif
1202+
assert(tp_version != 0);
1203+
write_u32(lm_cache->type_version, tp_version);
11991204
/* borrowed */
12001205
write_obj(lm_cache->descr, fget);
12011206
specialize(instr, LOAD_ATTR_PROPERTY);

0 commit comments

Comments
 (0)