diff options
-rw-r--r-- | source/blender/python/BPY_interface.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 70805d71ece..ba826ace4bc 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -396,6 +396,8 @@ int BPY_txt_do_python(struct SpaceText* st) if (!st->text) return 0; + PyErr_Clear(); + /* check if this text is already running */ while (script) { if (!strcmp(script->id.name+2, st->text->id.name+2)) { @@ -476,7 +478,7 @@ int BPY_menu_do_python(short menutype, int event) BPyMenu *pym; BPySubMenu *pysm; FILE *fp = NULL; - char *buffer; + char *buffer, *s; char filestr[FILE_MAXDIR+FILE_MAXFILE]; char dirname[FILE_MAXDIR]; Script *script = G.main->script.first; @@ -486,6 +488,8 @@ int BPY_menu_do_python(short menutype, int event) if (!pym) return 0; + PyErr_Clear(); + if (pym->version > G.version) notice ("Version mismatch: script was written for Blender %d. " "It may fail with yours: %d.", pym->version, G.version); @@ -523,8 +527,8 @@ int BPY_menu_do_python(short menutype, int event) BLI_make_file_string("/", filestr, dirname, pym->filename); } - fp = fopen(filestr, "r"); - if (!fp) { /* later also support userhome/.blender/scripts/ or whatever */ + fp = fopen(filestr, "rb"); + if (!fp) { printf("Error loading script: couldn't open file %s\n", filestr); return 0; } @@ -572,6 +576,9 @@ int BPY_menu_do_python(short menutype, int event) buffer[len] = '\0'; + /* fast clean-up of dos lines */ + for (s = buffer; *s != '\0'; s++) if (*s == '\r') *s = ' '; + fclose(fp); /* run the string buffer */ |