Skip to content

Commit a3d1b50

Browse files
add cases, use pytype_check only
1 parent ad4ff6e commit a3d1b50

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Python/specialize.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ specialize_dict_access(
552552
_PyAdaptiveEntry *cache0, _PyAttrCache *cache1,
553553
int base_op, int split_op, int hint_op)
554554
{
555-
assert(kind == NON_OVERRIDING || kind == NON_DESCRIPTOR || kind == ABSENT);
555+
assert(kind == NON_OVERRIDING || kind == NON_DESCRIPTOR || kind == ABSENT ||
556+
kind == BUILTIN_CLASSMETHOD || kind == PYTHON_CLASSMETHOD);
556557
// No desciptor, or non overriding.
557558
if (type->tp_dictoffset < 0) {
558559
SPECIALIZATION_FAIL(base_op, SPEC_FAIL_OUT_OF_RANGE);
@@ -696,6 +697,8 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, Sp
696697
case GETSET_OVERRIDDEN:
697698
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OVERRIDDEN);
698699
goto fail;
700+
case BUILTIN_CLASSMETHOD:
701+
case PYTHON_CLASSMETHOD:
699702
case NON_OVERRIDING:
700703
case NON_DESCRIPTOR:
701704
case ABSENT:
@@ -775,6 +778,8 @@ _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, S
775778
case GETSET_OVERRIDDEN:
776779
SPECIALIZATION_FAIL(STORE_ATTR, SPEC_FAIL_OVERRIDDEN);
777780
goto fail;
781+
case BUILTIN_CLASSMETHOD:
782+
case PYTHON_CLASSMETHOD:
778783
case NON_OVERRIDING:
779784
case NON_DESCRIPTOR:
780785
case ABSENT:
@@ -844,8 +849,7 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
844849
int owner_has_dict = (owner_dictptr != NULL && *owner_dictptr != NULL);
845850
PyDictObject *owner_dict = owner_has_dict ? (PyDictObject *)*owner_dictptr : NULL;
846851
// Check for classmethods.
847-
int owner_is_class = (owner_cls->tp_getattro != PyObject_GenericGetAttr) &&
848-
PyType_Check(owner);
852+
int owner_is_class = PyType_Check(owner);
849853
owner_cls = owner_is_class ? (PyTypeObject *)owner : owner_cls;
850854

851855
PyObject *descr = NULL;

0 commit comments

Comments
 (0)