This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: complex.__lt__ should return NotImplemented instead of raising TypeError
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: ezio.melotti, mark.dickinson, rhettinger
Priority: normal Keywords: patch

Created on 2010-02-03 13:58 by mark.dickinson, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7845.patch mark.dickinson, 2010-02-22 17:41
Messages (4)
msg98783 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-02-03 13:58
Currently in py3k, order comparisons for complex numbers raise a TypeError.  This was necessary in Python 2.x in order to make a complex <-> complex comparison raise an exception.  In 3.x, it's no longer necessary, since if both sides of a comparison return NotImplemented the result of the comparison is a TypeError (in 2.x the result is a value based on comparing the ids).

In py3k, complex.__lt__ could be changed to always return NotImplemented.  This would allow a custom class to implement its own comparisons with complex, and would remove an unnecessary special case.
msg98790 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-02-03 16:53
+1
msg99795 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-02-22 17:41
Here's a patch.
msg100999 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-03-13 09:51
Applied in r78902.
History
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52093
2010-03-13 09:51:34mark.dickinsonsetstatus: open -> closed
resolution: accepted
messages: + msg100999

stage: patch review -> resolved
2010-02-22 17:41:21mark.dickinsonsetfiles: + issue7845.patch
keywords: + patch
messages: + msg99795

stage: needs patch -> patch review
2010-02-03 20:44:09ezio.melottisetnosy: + ezio.melotti
2010-02-03 16:53:56rhettingersetnosy: + rhettinger
messages: + msg98790
2010-02-03 13:58:44mark.dickinsonsetstage: needs patch
2010-02-03 13:58:35mark.dickinsoncreate