summaryrefslogtreecommitdiffstats
path: root/Python/specialize.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-02-01 19:39:32 (GMT)
committerGitHub <noreply@github.com>2024-02-01 19:39:32 (GMT)
commite66d0399cc2e78fcdb6a0113cd757d2ce567ca7c (patch)
treed10f93e048e5f0814607ac397e23e525b1dc0144 /Python/specialize.c
parent97cc58f9777ee8b8e91f4ca8726cdb9f79cf906c (diff)
downloadcpython-e66d0399cc2e78fcdb6a0113cd757d2ce567ca7c.zip
cpython-e66d0399cc2e78fcdb6a0113cd757d2ce567ca7c.tar.gz
cpython-e66d0399cc2e78fcdb6a0113cd757d2ce567ca7c.tar.bz2
GH-114806. Don't specialize calls to classes with metaclasses. (GH-114870)
Diffstat (limited to 'Python/specialize.c')
-rw-r--r--Python/specialize.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/specialize.c b/Python/specialize.c
index a9efbe0..e38e355 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -540,6 +540,7 @@ _PyCode_Quicken(PyCodeObject *code)
#define SPEC_FAIL_CALL_METHOD_WRAPPER 28
#define SPEC_FAIL_CALL_OPERATOR_WRAPPER 29
#define SPEC_FAIL_CALL_INIT_NOT_SIMPLE 30
+#define SPEC_FAIL_CALL_METACLASS 31
/* COMPARE_OP */
#define SPEC_FAIL_COMPARE_OP_DIFFERENT_TYPES 12
@@ -1757,6 +1758,10 @@ specialize_class_call(PyObject *callable, _Py_CODEUNIT *instr, int nargs)
SPEC_FAIL_CALL_STR : SPEC_FAIL_CALL_CLASS_NO_VECTORCALL);
return -1;
}
+ if (Py_TYPE(tp) != &PyType_Type) {
+ SPECIALIZATION_FAIL(CALL, SPEC_FAIL_CALL_METACLASS);
+ return -1;
+ }
if (tp->tp_new == PyBaseObject_Type.tp_new) {
PyFunctionObject *init = get_init_for_simple_managed_python_class(tp);
if (type_get_version(tp, CALL) == 0) {