Bug in PyCallable_Check

Heiko Wundram heikowu at ceosg.de
Mon May 3 08:02:44 EDT 2004


Am Montag, 3. Mai 2004 13:39 schrieb Arkon:
> And then the PyCallable_Check won't *detect* that it's not a real
> function(pointer) passed...then later when you intend to run that
> function, you get an error.

PyCallable_Check does as it is told, it checks whether the argument can be 
called.

There are loads of callable things in Python, method references being just one 
of them. A class is callable (instantiation or overridden __metaclass__ or 
the like), an instance is callable (using the __call__ method of the class), 
and many other things too. What you're seeing (complaining about) is that 
types are nothing else than classes, and so they are callable too.

If you really have to check that it is a function, you'll have to check the 
type of the reference for types.FunctionType.

HTH!

Heiko.




More information about the Python-list mailing list