Skip to content

Commit def326e

Browse files
Address review, make things more restrictive
1 parent cb7d01e commit def326e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Python/specialize.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ miss_counter_start(void) {
389389
#define SPEC_FAIL_ATTR_HAS_MANAGED_DICT 25
390390
#define SPEC_FAIL_ATTR_INSTANCE_ATTRIBUTE 26
391391
#define SPEC_FAIL_ATTR_METACLASS_ATTRIBUTE 27
392+
#define SPEC_FAIL_ATTR_PROPERTY_NOT_PY_FUNCTION 28
392393

393394
/* Binary subscr and store subscr */
394395

@@ -594,7 +595,9 @@ analyze_descriptor(PyTypeObject *type, PyObject *name, PyObject **descr, int sto
594595
getattribute != interp->callable_cache.object__getattribute__;
595596
has_getattr = _PyType_Lookup(type, &_Py_ID(__getattr__)) != NULL;
596597
if (has_custom_getattribute) {
597-
if (!has_getattr && Py_IS_TYPE(getattribute, &PyFunction_Type)) {
598+
if (getattro_slot == _Py_slot_tp_getattro &&
599+
!has_getattr &&
600+
Py_IS_TYPE(getattribute, &PyFunction_Type)) {
598601
*descr = getattribute;
599602
return GETATTRIBUTE_IS_PYTHON_FUNCTION;
600603
}
@@ -772,7 +775,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
772775
goto fail;
773776
}
774777
if (!Py_IS_TYPE(fget, &PyFunction_Type)) {
775-
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_NOT_PY_FUNCTION);
778+
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_PROPERTY_NOT_PY_FUNCTION);
776779
goto fail;
777780
}
778781
uint32_t version = function_check_args(fget, 1, LOAD_ATTR) &&

0 commit comments

Comments
 (0)