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.

Author rhettinger
Recipients Chris.Tandiono, mark.dickinson, rhettinger
Date 2013-03-09.22:57:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
A negative value will almost never be the cause of this exception.

The proposed new message is more accurate but is also less useful and informative.  Getting a ValueError exception already means "the value is invalid".  The job of the message is to suggest the likely cause so a person will no what to do about it. 

That said, I'll tweak the message at some point but I'm rejecting the patch as-is because I believe it makes the message worse rather better.

Please do keep looking for ways to improve Python's error messages and make them as useful as possible.

Here's food for thought:  In Py2.x, the error message for len(obj) is different depending on whether it is a new-style or old-style class.  If someone has forgotten to add the appropriate magic method to their class, which message would be the most helpful:

>>> class A(object): pass

>>> len(A())
Traceback (most recent call last):
TypeError: object of type 'A' has no len()

>>> class A: pass
>>> len(A())
Traceback (most recent call last):
AttributeError: A instance has no attribute '__len__'
Date User Action Args
2013-03-09 22:57:37rhettingersetrecipients: + rhettinger, mark.dickinson, Chris.Tandiono
2013-03-09 22:57:36rhettingersetmessageid: <>
2013-03-09 22:57:36rhettingerlinkissue17388 messages
2013-03-09 22:57:36rhettingercreate