C-API PyObject_Call

Stefan Behnel stefan_ml at behnel.de
Sat Mar 20 10:44:39 CET 2010


moerchendiser2k3, 20.03.2010 03:01:
> Yes, the user is able to set a file which contains a function that
> does what the user wants.
 > But in a case, I expect a special return value of this function.

Ah, ok, that was the important piece of information that you omitted from 
your previous posts. So what you actually do is call a user provided 
function and you want to report errors back to the user if the function 
does not behave as expected by the (plugin) interface, and not only when it 
raises an exception itself.

You might want to read this:

http://catb.org/~esr/faqs/smart-questions.html


> So, I need to tell him, in which file/line the error occured,
> otherwise he dont know where to look.
>
> Imagine he set 20 files, and all of them have implemented a special
> function. So he wouldnt know where to check for the error.

Well, you can easily get at the module file path and the function name 
through introspection of the function, just as you would in Python. That 
should be enough information to present to the user. I don't see why you 
would want to add the exact line number of the return statement. The inner 
workings of the user function you call are up to the user, after all.

Again, take a look at Cython, where you can do the introspection in Python 
code.

Stefan




More information about the Python-list mailing list