mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
GH-94822: Don't specialize when metaclasses are involved (GH-94892)
This commit is contained in:
parent
c41d4d0917
commit
daf68ba92f
3 changed files with 351 additions and 6 deletions
|
@ -945,6 +945,10 @@ specialize_class_load_attr(PyObject *owner, _Py_CODEUNIT *instr,
|
|||
PyObject *name)
|
||||
{
|
||||
_PyLoadMethodCache *cache = (_PyLoadMethodCache *)(instr + 1);
|
||||
if (!PyType_CheckExact(owner) || _PyType_Lookup(Py_TYPE(owner), name)) {
|
||||
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_METACLASS_ATTRIBUTE);
|
||||
return -1;
|
||||
}
|
||||
PyObject *descr = NULL;
|
||||
DescriptorClassification kind = 0;
|
||||
kind = analyze_descriptor((PyTypeObject *)owner, name, &descr, 0);
|
||||
|
@ -957,12 +961,7 @@ specialize_class_load_attr(PyObject *owner, _Py_CODEUNIT *instr,
|
|||
return 0;
|
||||
#ifdef Py_STATS
|
||||
case ABSENT:
|
||||
if (_PyType_Lookup(Py_TYPE(owner), name) != NULL) {
|
||||
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_ATTR_METACLASS_ATTRIBUTE);
|
||||
}
|
||||
else {
|
||||
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_EXPECTED_ERROR);
|
||||
}
|
||||
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_EXPECTED_ERROR);
|
||||
return -1;
|
||||
#endif
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue