diff options
| author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-07-18 18:55:07 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-18 18:55:07 (GMT) |
| commit | eda2f90094731a7a1a30bc4a50a6c1bc050a4b2c (patch) | |
| tree | fcd53d93cae963ef32d8d607d4a5439062d8d553 /Python/specialize.c | |
| parent | a5c8cecf294716d05f5aaf740321cb57ccc84b46 (diff) | |
| download | cpython-eda2f90094731a7a1a30bc4a50a6c1bc050a4b2c.zip cpython-eda2f90094731a7a1a30bc4a50a6c1bc050a4b2c.tar.gz cpython-eda2f90094731a7a1a30bc4a50a6c1bc050a4b2c.tar.bz2 | |
[3.11] GH-94822: Don't specialize when metaclasses are involved (GH-94892) (GH-94980)
(cherry picked from commit daf68ba92f315bfd239a0c993f9f683fb90325fb)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
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 cf7bc32..5f2c6b3 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -871,6 +871,10 @@ specialize_class_load_method(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_METHOD, SPEC_FAIL_LOAD_METHOD_METACLASS_ATTRIBUTE); + return -1; + } PyObject *descr = NULL; DescriptorClassification kind = 0; kind = analyze_descriptor((PyTypeObject *)owner, name, &descr, 0); @@ -883,12 +887,7 @@ specialize_class_load_method(PyObject *owner, _Py_CODEUNIT *instr, return 0; #ifdef Py_STATS case ABSENT: - if (_PyType_Lookup(Py_TYPE(owner), name) != NULL) { - SPECIALIZATION_FAIL(LOAD_METHOD, SPEC_FAIL_LOAD_METHOD_METACLASS_ATTRIBUTE); - } - else { - SPECIALIZATION_FAIL(LOAD_METHOD, SPEC_FAIL_EXPECTED_ERROR); - } + SPECIALIZATION_FAIL(LOAD_METHOD, SPEC_FAIL_EXPECTED_ERROR); return -1; #endif default: |
