Bug in PyCallable_Check

Arkon arkon at ragestorm.net
Mon May 3 15:27:18 EDT 2004


Heiko Wundram <heikowu at ceosg.de> wrote in message news:<mailman.207.1083585752.25742.python-list at python.org>...
> 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.

Well, I wasn't sure from the beginning,
but thanks for making it clear to me, I haven't thought of it in that way!

As for Diez B. Roggisch example
I get "TypeError: cannot create 'function' instances"...

Arkon



More information about the Python-list mailing list