[Bf-python] PyRun_File vs PyRun_String
Willian Padovani Germano
wpgermano at gmail.com
Sun May 11 21:51:08 CEST 2008
Hi,
Campbell: I wrote that comment about PyRun_File, back when scripts from
menus functionality was added. First I used PyRun_File, it worked fine
under Linux. But when committed to cvs, we got reports about crashes on
Windows. I searched around and saw that comment on the Python C/API
reference manual. So then I changed it to PyRun_String and also had to
parse the file to fix line ending issues, after more error reports.
Besides your proposed solution, another thing that could be done is to
use Blender's add_text() function, since Blender doesn text cleanup
well, afaik. Add text to Blender, run it (or first get it to a buffer),
then remove the text as soon as it isn't needed anymore.
Don't know if there's any chance of this removal crashing Blender in
special circumstances (open Text Editor win with no texts or whatever),
but it's worth testing, at least. I mentioned this to Nathan
(jesterKing) some time ago, since PyNodes will also need code to load
scripts directly from the file system, a feature to be added after this
release.
--
Willian
More information about the Bf-python
mailing list