Author terry.reedy
Recipients eric.araujo, ezio.melotti, o11c, steven.daprano, terry.reedy
Date 2012-07-07.01:44:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341625499.81.0.770893413103.issue15248@psf.upfronthosting.co.za>
In-reply-to
Content
Stephen is right; this sort of guess-the-bug heuristic is out of scope for the CPython interpreter. I believe you grossly under estimate the difficulty of such a this. Consider that idea rejected.

What *is* disconcerting is the exact form of the error message for this particular code pattern:

Traceback (most recent call last):
  File "<pyshell#0>", line 3, in <module>
    (4, 5, 6)
TypeError: 'tuple' object is not callable

Uh... There was no attempt to call the tuple (4,5,6), which was misinterpreted as a () call operator with 3 args. What might be a reasonable request is to print a size-limited representation of the object that is not callable but was attempted to be called. Truncated representations would be generally useful for traceback messages. I believe we already have them for unittest error messages.

A useful document for someone (or some people) to write would be 'How to interpret exception messages'. That could start with a catalog of messages and possible causes. 'type' would be used to stand for any specific type.

The section on TypeErrors would have an heading
  'type' object is not callable
followed by an explanation
  There are two general reasons for this message. The first is that you intentionally write "expression(args)" with the intent that expression evaluate to a callable, but it does not. The second is that you accidentally omit a comma in a sequence and write "expression (tuple_members)". Note that the error is triggered by the "(args)" call operator and its line is the one printed. So if "expression" is on the preceeding line, it will not appear in the traceback. This can happen with either type of error.

In the meanwhile, the above is a start for a faq entry.
History
Date User Action Args
2012-07-07 01:44:59terry.reedysetrecipients: + terry.reedy, ezio.melotti, eric.araujo, steven.daprano, o11c
2012-07-07 01:44:59terry.reedysetmessageid: <1341625499.81.0.770893413103.issue15248@psf.upfronthosting.co.za>
2012-07-07 01:44:59terry.reedylinkissue15248 messages
2012-07-07 01:44:58terry.reedycreate