PyEval_EvalCodeEx return value

Mateusz Loskot mateusz at loskot.net
Sat Sep 24 16:52:46 EDT 2011



John Pinner-3 wrote:
> 
> I assume that you have read the documentation at
> http://docs.python.org/c-api/veryhigh.html,
> and I agree that it's sparse, but the entry for the next entry,
> PyEval_EvalCodeEx, tells you a little more, as does that for
> PyEval_EvalFrameEx.
> 

It does help, but only a bit.


John Pinner-3 wrote:
> 
> Obviously, it's returning a pointer to a PyObject, and Looking at the
> source code, that may be NULL, to throw an exception, or an execution
> frame, or a generator,etc, etc, depending on the code it's been given.
> I guess that you should be able to inspect the PyObject to see what it is.
> 

Yes, that's one possibility. I tried to investigate others.


John Pinner-3 wrote:
> 
> What I'm wondering is, why are you eval-ing code ? A favourite device
> of C programmers coming to Python (and mea culpa in the past), it's
> fraught with potential problems and even security risks, and is
> difficult to debug, and maybe you should be using introspection instead.
> 

My application accepts Python scripts from user and executes using embedded
Python interpreter.
So, I use this particular API.

Could you elaborate on the "using introspection"?


John Pinner-3 wrote:
> 
> And maybe you should be working in Python, and not C++ at this point,
> do the dynamic stuff in the language best suited, and then return to C++
> when needed.
> 

My application in C++ interacts with Python programs provided by users.
Depending on what these programs request, various PyObject objects are
created and returned back, etc.

I understand it's difficult to discuss it without long essays or without
providing the code, etc.
So, I can only discuss and investigate building blocks I use.
Anyway, thanks for your comments.

Best regards,

-----
-- 
Mateusz Loskot
http://mateusz.loskot.net
-- 
View this message in context: http://old.nabble.com/PyEval_EvalCodeEx-return-value-tp32501833p32503908.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list