[Python-checkins] Simplify defaultdict.__or__ (#18931)

Brandt Bucher webhook-mailer at python.org
Thu Mar 12 00:06:51 EDT 2020


https://github.com/python/cpython/commit/1dd3794b19cfec448e5a55d8d01efd6bdb5a1169
commit: 1dd3794b19cfec448e5a55d8d01efd6bdb5a1169
branch: master
author: Brandt Bucher <brandtbucher at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-03-11T21:06:46-07:00
summary:

Simplify defaultdict.__or__ (#18931)

files:
M Modules/_collectionsmodule.c

diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index d0a381deabf5d..fd0e4edcddfdb 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;
     }



More information about the Python-checkins mailing list