From 0bd735a4e11b54d3025485dc7db2c6a4b6a36b65 Mon Sep 17 00:00:00 2001 From: Itamar Ostricher Date: Tue, 27 Dec 2022 07:46:56 -0800 Subject: [PATCH] Backport gh-29392: Use PyObject_TypeCheck in type_call and binary_op1 Summary: Upstream issue: /~https://github.com/python/cpython/issues/89860 Upstream PR: /~https://github.com/python/cpython/pull/29392 This also ports D14351113 + D32175230 from 3.8 to 3.10 Test Plan: CI Reviewers: alexanderm, #cinder Reviewed By: alexanderm Differential Revision: https://phabricator.intern.facebook.com/D42229775 Tags: cinder-310-upstream-complete, accept2ship, cinder-310-standalone-upstream-candidate --- Objects/typeobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 02423be070c..b75b579943c 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1235,7 +1235,7 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds) /* If the returned object is not an instance of type, it won't be initialized. */ - if (!PyType_IsSubtype(Py_TYPE(obj), type)) + if (!PyObject_TypeCheck(obj, type)) return obj; type = Py_TYPE(obj);