From 1dd3794b19cfec448e5a55d8d01efd6bdb5a1169 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 11 Mar 2020 21:06:46 -0700 Subject: [PATCH] Simplify defaultdict.__or__ (#18931) --- Modules/_collectionsmodule.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index d0a381deabf..fd0e4edcddf 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -2133,12 +2133,8 @@ defdict_repr(defdictobject *dd) static PyObject* defdict_or(PyObject* left, PyObject* right) { - int left_is_self = PyObject_IsInstance(left, (PyObject*)&defdict_type); - if (left_is_self < 0) { - return NULL; - } PyObject *self, *other; - if (left_is_self) { + if (PyObject_TypeCheck(left, &defdict_type)) { self = left; other = right; }