[Python-3000] PEP 3100 Comments
Steven Bethard
steven.bethard at gmail.com
Mon May 8 17:47:24 CEST 2006
On 5/8/06, Barry Warsaw <barry at python.org> wrote:
> Perhaps then, if we get rid of callable()/PyCallable_Check() it would be
> useful to add a NotCallableError (as a subclass of TypeError?) that
> would get thrown should you try to call something that's not callable.
> The argument to the exception would be the thing you tried to
> erroneously called.
+1. It'd certainly be nice to be able to tell the difference between
the following two TypeErrors:
>>> def s():
... raise TypeError()
...
>>> 's'()
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: 'str' object is not callable
>>> s()
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "<interactive input>", line 2, in s
TypeError
A few places that look like they'd need to be changed:
Modules/_tkinter.c: PyErr_SetString(PyExc_TypeError,
"command not callable");
Objects/abstract.c: PyErr_Format(PyExc_TypeError, "'%s' object is
not callable",
Objects/funcobject.c: PyErr_Format(PyExc_TypeError, "'%s'
object is not callable",
STeVe
--
Grammar am for people who can't think for myself.
--- Bucky Katt, Get Fuzzy
More information about the Python-3000
mailing list