Capturing PyRun_String stdout

2015-07-01 Thread Chris Moller
language and I need to capture the output of PyRun_String(), PyEval_EvalCode(), or whatever as a char * (or wchar_t * or whatever) rather than have it go to stdout. I'm using Python 3.3.2 under plain C, not C++ And, while I'm interrupting everyone's evening, another question:

Capturing PyRun_String stdout

2015-07-01 Thread Chris Moller
language and I need to capture the output of PyRun_String(), PyEval_EvalCode(), or whatever as a char * (or wchar_t * or whatever) rather than have it go to stdout. I'm using Python 3.3.2 under plain C, not C++ And, while I'm interrupting everyone's evening, another question:

Re: problem using import from PyRun_String

2008-04-11 Thread Patrick Stinson
; Well, I eventually want to add an import hook, but for now I'd rather > > just > > get the import statement working normally again. > > I have embedded python as a scripting engine in my application. To do > > this, > > I create a new empty module, run the sc

Re: problem using import from PyRun_String

2008-04-09 Thread Gabriel Genellina
ication. To do > this, > I create a new empty module, run the script text using PyRun_String() > passing the module's __dict__ as locals and globals. This populates the > module's __dict__ with the resulting object references from the script > text. Instead of PyRun_St

Re: problem using import from PyRun_String

2008-04-09 Thread Patrick Stinson
Well, I eventually want to add an import hook, but for now I'd rather just get the import statement working normally again. I have embedded python as a scripting engine in my application. To do this, I create a new empty module, run the script text using PyRun_String() passing the mod

Re: problem using import from PyRun_String

2008-04-09 Thread Gabriel Genellina
En Tue, 08 Apr 2008 22:01:18 -0300, Patrick Stinson <[EMAIL PROTECTED]> escribió: > I'm creating a module with PyModule_New(), and running a string buffer as > the module's text using PyRun_String and passing the module's __dict__ to > locals and globals. Why? D

problem using import from PyRun_String

2008-04-08 Thread Patrick Stinson
I'm creating a module with PyModule_New(), and running a string buffer as the module's text using PyRun_String and passing the module's __dict__ to locals and globals. I'm having a problem using the import statement from within PyRun_String(). It complains about "__import_

Re: PyRun_String using my module in a def

2007-07-05 Thread Alex Martelli
to use main_dict.update(dlfl_dict) > (Python code) or PyDict_Update(main_dict, dlfl_dict) (in C code). Yep. > > I tried PyObject *rstring = PyRun_String( cmd, Py_file_input, > > dlfl_dict, dlfl_dict ); > > This worked, but has the side effect of not allowing other commands

Re: PyRun_String using my module in a def

2007-07-05 Thread Gabriel Genellina
ict) (in C code). > I tried PyObject *rstring = PyRun_String( cmd, Py_file_input, > dlfl_dict, dlfl_dict ); > This worked, but has the side effect of not allowing other commands > like "execfile" The idea is to copy all items from dlfl_dict into main_dict, and use main_di

Re: PyRun_String using my module in a def

2007-07-04 Thread Stuart
What command do you mean when you say "update main_dict with dlfl_dict"? I tried PyObject *rstring = PyRun_String( cmd, Py_file_input, dlfl_dict, dlfl_dict ); This worked, but has the side effect of not allowing other commands like "execfile" I was able to type that before,

Re: PyRun_String using my module in a def

2007-07-04 Thread Alex Martelli
Stuart <[EMAIL PROTECTED]> wrote: ... > PyObject *rstring = PyRun_String( cmd, Py_file_input, main_dict, > dlfl_dict ); You're passing difl_dict as the "locals" to PyRun_String -- but a function has its own locals, so it won't use those locals. Just update main

PyRun_String using my module in a def

2007-07-04 Thread Stuart
ict( main ); PyObject* dlfl_dict = PyModule_GetDict( dlfl ); PyObject *rstring = PyRun_String( cmd, Py_file_input, main_dict, dlfl_dict ); rstring returns NULL and then PyErr_Fetch( &object, &data, &traceback ); gets the traceback string as I mentioned above. Hopefully, there is just a simple solution. Thanks :) -- http://mail.python.org/mailman/listinfo/python-list

Re: PyRun_String with Py_single_input to stdout?

2007-06-18 Thread [EMAIL PROTECTED]
0, [EMAIL PROTECTED] > <[EMAIL PROTECTED]> escribió: > > > I'm using PyRun_String with Py_single_input for a python interpreter > > embedded in my application. I'm using Py_single_input. Py_single input > > is what I want, but it seems to output to stdout. Befor

Re: PyRun_String with Py_single_input to stdout?

2007-06-18 Thread Gabriel Genellina
En Mon, 18 Jun 2007 01:45:38 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > I'm using PyRun_String with Py_single_input for a python interpreter > embedded in my application. I'm using Py_single_input. Py_single input > is what I want, but it seems to output

PyRun_String with Py_single_input to stdout?

2007-06-17 Thread [EMAIL PROTECTED]
I'm using PyRun_String with Py_single_input for a python interpreter embedded in my application. I'm using Py_single_input. Py_single input is what I want, but it seems to output to stdout. Before when I was using Py_eval_input I was able to grab the result so I could print it in

PyRun_String with Py_single_input to stdout?

2007-06-17 Thread [EMAIL PROTECTED]
I'm using PyRun_String with Py_single_input for a python interpreter embedded in my application. I'm using Py_single_input. Py_single input is what I want, but it seems to output to stdout. Before when I was using Py_eval_input I was able to grab the result so I could print it in

Re: PyRun_String and related functions causing garbage when calling a parsed function from C.

2007-05-13 Thread Gabriel Genellina
d to python embedding > it). I have a function that executes a string buffer of python code, > fetches a function from its global dictionary then calls it. Why don't you use a documented function like PyRun_String or similar, as in the subject line? > /*Now for the fun par

PyRun_String and related functions causing garbage when calling a parsed function from C.

2007-05-13 Thread joeedh
Hi I'm getting extremely odd behavior. First of all, why isn't PyEval_EvalCode documented anywhere? Anyway, I'm working on blender's python integration (it embeds python, as opposed to python embedding it). I have a function that executes a string buffer of python code, fetches a function from

Re: PyRun_String

2006-03-09 Thread Matthias
Am Thu, 09 Mar 2006 20:06:54 +0100 hat Duncan Booth <[EMAIL PROTECTED]> geschrieben: > Matthias wrote: > >> Log("Marker 1"); >> Py_XDECREF( PyRun_String( "print 'Hi!'", Py_single_input, Dict, Dict) ); >> Log("Marker 2")

Re: PyRun_String

2006-03-09 Thread Duncan Booth
Matthias wrote: > Log("Marker 1"); > Py_XDECREF( PyRun_String( "print 'Hi!'", Py_single_input, Dict, Dict) ); > Log("Marker 2"); > > The output looks like > > Marker 1 > Hi! > Hi! > Marker 2 > > Obviously Hi! is printe

PyRun_String

2006-03-09 Thread Matthias
Hello, I encountered a strange problem today. I try to do this: Log("Marker 1"); Py_XDECREF( PyRun_String( "print 'Hi!'", Py_single_input, Dict, Dict) ); Log("Marker 2"); The output looks like Marker 1 Hi! Hi! Marker 2 Obviously Hi! is printed twice. I&

PyRun_String does not appear to handle EInvalidOp exceptions

2005-06-06 Thread Heather Korns
Here's a snippet of code that demonstrates my problem: result = PyRun_String ("import math", Py_file_input, pdict,pdict); result = PyRun_String ("math.sqrt(-1)", Py_file_input, pdict,pdict); result = PyRun_String ("math.pow(2,1024)", Py_file_input, pdict,