Title: Traceback changed in 2.6 for unhashable objects
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, mg, r.david.murray
Priority: low Keywords:

Created on 2008-03-25 21:28 by mg, last changed 2009-03-24 20:21 by benjamin.peterson. This issue is now closed.

Messages (3)
msg64517 - (view) Author: Martin Geisler (mg) Date: 2008-03-25 21:28
The traceback message given when trying to hash unhashable objects has
changed from Python 2.5 to 2.6:

Python 2.5.2a0 (r251:54863, Feb 10 2008, 01:31:28) 
>>> hash([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: list objects are unhashable

Python 2.6a1 (r26a1:61143, Mar 25 2008, 19:41:30) 
>>> hash([])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'

This breaks my Doctests unless I add a somewhat ugly "# doctest:
+IGNORE_EXCEPTION_DETAIL" comment, so if this is not done on purpose, I
would prefer Python 2.6 to output the same as 2.5.
msg84095 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-03-24 17:02
In 2.5, the fact that list was unhashable was checked in the list
object, and that message was hardcoded there.  In 2.6, the check for
unhashableness uses generic code, and the resulting error substitutes
the type name into the message.  This message already existed and was
used for other types, the difference between 2.5 and 2.6 is that list is
now covered by the generic code and is not a special case.

So, yes, this was intentional and no, it isn't going to get changed.
msg84111 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-03-24 20:21
Error messages are not part of the API.
Date User Action Args
2009-03-24 20:21:28benjamin.petersonsetstatus: pending -> closed

nosy: + benjamin.peterson
messages: + msg84111

resolution: wont fix -> not a bug
2009-03-24 17:02:01r.david.murraysetstatus: open -> pending
priority: low

components: + Interpreter Core

nosy: + r.david.murray
messages: + msg84095
resolution: wont fix
stage: resolved
2008-03-25 21:28:01mgcreate