summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS4
-rw-r--r--Objects/object.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 9363694191..c63db58bdd 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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;