diff options
| author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-07-18 17:10:22 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-18 17:10:22 (GMT) |
| commit | daf68ba92f315bfd239a0c993f9f683fb90325fb (patch) | |
| tree | 41e81bc487e49cdb08ea51dc13801d983209a431 /Python/specialize.c | |
| parent | c41d4d09172bf28ba9e5760498bd494a3521a123 (diff) | |
| download | cpython-daf68ba92f315bfd239a0c993f9f683fb90325fb.zip cpython-daf68ba92f315bfd239a0c993f9f683fb90325fb.tar.gz cpython-daf68ba92f315bfd239a0c993f9f683fb90325fb.tar.bz2 | |
GH-94822: Don't specialize when metaclasses are involved (GH-94892)
Diffstat (limited to 'Python/specialize.c')
| -rw-r--r-- | Python/specialize.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index 66cae44..6f1f3cb 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -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: |
