diff options
-rw-r--r-- | Misc/NEWS | 4 | ||||
-rw-r--r-- | Objects/object.c | 5 |
2 files changed, 8 insertions, 1 deletions
@@ -163,6 +163,10 @@ Build C API +- PyNumber_Coerce() and PyNumber_CoerceEx() now also invoke the type's + coercion if both arguments have the same type but this type has the + CHECKTYPES flag set. This is to better support proxies. + - The type of tp_free has been changed from "void (*)(PyObject *)" to "void (*)(void *)". diff --git a/Objects/object.c b/Objects/object.c index e47f80ea5b..85fd35fc6b 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1427,7 +1427,10 @@ PyNumber_CoerceEx(PyObject **pv, PyObject **pw) register PyObject *w = *pw; int res; - if (v->ob_type == w->ob_type && !PyInstance_Check(v)) { + /* Shortcut only for old-style types */ + if (v->ob_type == w->ob_type && + !PyType_HasFeature(v->ob_type, Py_TPFLAGS_CHECKTYPES)) + { Py_INCREF(v); Py_INCREF(w); return 0; |