[pygtk] Can't run PyGTK more than once from embedded Python

Romain Behar romainbehar at yahoo.com
Tue Jan 10 04:45:08 WST 2006


Thanks for all your answers, even if they're bad news.

I'll like to try this one, as the two other as
impractical (rewritting the application in Python, or
having a single interpreter).

> > You can have different namespaces inside the
> > same interpreter.
> 
> Right.  Unfortunately there *are* limits to
> this approach in so far as imported modules
> can act as a sort of global namespace, with
> potentially undesirable consequences.

Why running the script using:

 PyRun_String(my_script, 0, 0, 0);

or:

 PyObject* main_module =
PyImport_AddModule("__main__");
 PyObject* main_dict = PyModule_GetDict(main_module);
 PyRun_String(my_script, 0, main_dict, main_dict);

does nothing? The script runs  and ends, but printed
messages don't show in the console and PyGTK windows
don't open. Is that what you call "using different
namespaces"?

If it does not work, the only solution will be to
patch PyGTK to behave as all other Python modules...

> Here is an important question - are the scripts
> you are launching ones that you have written
> and are supplying with your main application, or
> are they being written by end-users?  And what
> is your level of responsibility if one of these
> scripts did something evil?

Well, I'm in the worst case ;)
The application uses Python as scripting engine, it
imports the application's extension module. Anyone's
bound to write Python scripts to extend the
application!

 Cheers,

  Romain



		
__________________________________________ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 



More information about the pygtk mailing list