classification
Title: Raise Py3K warnings for comparisons that changed
Type: Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: bethard Nosy List: benjamin.peterson, bethard
Priority: critical Keywords: 26backport, patch

Created on 2008-03-17 22:10 by bethard, last changed 2008-07-31 01:57 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
changed_comparisons.patch bethard, 2008-03-18 06:53
Messages (9)
msg63792 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-17 22:10
Some comparisons were changed or removed in Python 3.0. In 2.6 you could
compare types (e.g. ``str < int``) and dicts supported more than just
equality. These comparisons should produce Py3K warnings.
msg63901 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-18 06:53
I'm attaching a patch that handles object comparisons, type comparisons,
cell comparisons, and dict comparisons. All the tests pass (including
the new ones I've added) but I'd appreciate it if someone could take a
second look.

Other things still remaining to be done:

* Someone needs to decide the correct behavior for method-wrappers
(descrobject.c), implement that in Python 2.6 and forward port it to 3.0.

* The following objects have a good tp_richcompare in Python 3.0:
codeobject.c, methodobject.c, sliceobject.c. Those tp_richcompares
should be backported to 2.6. Then a warning can be added for LE, LT, GE
and GT (with no warning for EQ or NE which won't change).

I may have a little time tomorrow to work on the latter task.
msg63948 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-18 17:27
Revision 61529 adds warnings for object, type, cell and dict
comparisons. The code, method and slice warnings are still needed.
msg63954 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-03-18 17:57
Your patch kicks up warnings in Objects/cellobject.c because
cell_compare returns an int, your patch may return NULL.
msg63960 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-18 18:33
On Tue, Mar 18, 2008 at 11:57 AM, Benjamin Peterson
<report@bugs.python.org> wrote:
>  Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>
>  Your patch kicks up warnings in Objects/cellobject.c because
>  cell_compare returns an int, your patch may return NULL.

Thanks.  I'll fix that.

Steve
msg63962 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-18 18:38
So I believe it should be returning -2 instead of NULL.  Can someone
verify that -2 means raise an exception for tp_compare?
msg63963 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-18 19:04
Ok, that warning should be gone now in trunk.
msg63997 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-18 21:48
I took a closer look at sliceobject.c and it looks like both 2.6 and 3.0
compare them basically as tuples. So there don't need to be any warnings
about using < and > since these are still well defined.

I'll have a patch for codeobject.c and methodobject.c soon.
msg64000 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2008-03-18 22:19
Resolved in revision 61570. I can't get svnmerge block to work though.
Since the code and method changes are just backports of Python 3,
someone needs to run ``svnmerge.py block -r 61570``.
History
Date User Action Args
2008-07-31 01:57:34benjamin.petersonsetstatus: open -> closed
resolution: fixed
2008-03-18 22:19:37bethardsetmessages: + msg64000
2008-03-18 21:48:11bethardsetmessages: + msg63997
2008-03-18 19:04:48bethardsetmessages: + msg63963
2008-03-18 18:38:56bethardsetmessages: + msg63962
2008-03-18 18:33:42bethardsetmessages: + msg63960
2008-03-18 17:57:41benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg63954
2008-03-18 17:27:50bethardsetmessages: + msg63948
2008-03-18 06:53:07bethardsetfiles: + changed_comparisons.patch
keywords: + patch
messages: + msg63901
2008-03-17 22:10:33bethardcreate