diff options
author | Steven Bethard <steven.bethard@gmail.com> | 2008-03-18 17:26:10 +0000 |
---|---|---|
committer | Steven Bethard <steven.bethard@gmail.com> | 2008-03-18 17:26:10 +0000 |
commit | ae42f33cdfb68be2fc71be0fb67ec025f90160e8 (patch) | |
tree | 07985bc750d9266f2e725b6ba46b0f71c17c8d08 /Objects/object.c | |
parent | a8b09fd4c33572a204a80c81e5755cc6d164805d (diff) | |
download | cpython-git-ae42f33cdfb68be2fc71be0fb67ec025f90160e8.tar.gz |
Add py3k warnings for object, type, cell and dict comparisons. This should resolve issue2342 and partly resolve issue2373.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c index 698ba47601..a10ac7ce19 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -863,8 +863,18 @@ try_3way_to_rich_compare(PyObject *v, PyObject *w, int op) int c; c = try_3way_compare(v, w); - if (c >= 2) + if (c >= 2) { + + /* Py3K warning if types are not equal and comparison isn't == or != */ + if (Py_Py3kWarningFlag && + v->ob_type != w->ob_type && op != Py_EQ && op != Py_NE && + PyErr_Warn(PyExc_DeprecationWarning, + "comparing unequal types not supported in 3.x.") < 0) { + return NULL; + } + c = default_3way_compare(v, w); + } if (c <= -2) return NULL; return convert_3way_to_object(op, c); |