no longer crashes on mangled console.py and other python initialisation errors.
This commit is contained in:
parent
9c39875ef0
commit
8b22ca5064
BIN
build/powder
BIN
build/powder
Binary file not shown.
File diff suppressed because one or more lines are too long
62
src/main.c
62
src/main.c
@ -30,6 +30,7 @@
|
|||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pyconsole.h"
|
#include "pyconsole.h"
|
||||||
//#include "pystdlib.h"
|
//#include "pystdlib.h"
|
||||||
|
char pyready=1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -2090,7 +2091,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
printf("unable to find handle function, mangled console.py?\n");
|
printf("unable to find handle function, mangled console.py?\n");
|
||||||
return -1;
|
//return -1;
|
||||||
|
pyready=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pstep=PyObject_GetAttrString(pmodule,"step");//get the handler function
|
pstep=PyObject_GetAttrString(pmodule,"step");//get the handler function
|
||||||
@ -2118,7 +2120,8 @@ int main(int argc, char *argv[])
|
|||||||
//sys.stderr
|
//sys.stderr
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
printf("unable to find console module, missing file or mangled console.py?\n");
|
printf("unable to find console module, missing file or mangled console.py?\n");
|
||||||
return -1;
|
//return -1;
|
||||||
|
pyready=0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
printf("python console disabled at compile time.");
|
printf("python console disabled at compile time.");
|
||||||
@ -2748,18 +2751,19 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PYCONSOLE
|
#ifdef PYCONSOLE
|
||||||
if(pkey!=NULL && sdl_key!=NULL)
|
if(pyready==1)
|
||||||
{
|
if(pkey!=NULL && sdl_key!=NULL)
|
||||||
pargs=Py_BuildValue("(c)",sdl_key);
|
{
|
||||||
pvalue = PyObject_CallObject(pkey, pargs);
|
pargs=Py_BuildValue("(c)",sdl_key);
|
||||||
Py_DECREF(pargs);
|
pvalue = PyObject_CallObject(pkey, pargs);
|
||||||
pargs=NULL;
|
Py_DECREF(pargs);
|
||||||
if(pvalue==NULL)
|
pargs=NULL;
|
||||||
strcpy(console_error,"failed to execute key code.");
|
if(pvalue==NULL)
|
||||||
//Py_DECREF(pvalue);
|
strcpy(console_error,"failed to execute key code.");
|
||||||
//puts("a");
|
//Py_DECREF(pvalue);
|
||||||
pvalue=NULL;
|
//puts("a");
|
||||||
}
|
pvalue=NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef INTERNAL
|
#ifdef INTERNAL
|
||||||
int counterthing;
|
int counterthing;
|
||||||
@ -3660,6 +3664,8 @@ int main(int argc, char *argv[])
|
|||||||
if(console_mode)
|
if(console_mode)
|
||||||
{
|
{
|
||||||
#ifdef PYCONSOLE
|
#ifdef PYCONSOLE
|
||||||
|
if(pyready==1)
|
||||||
|
{
|
||||||
char *console;
|
char *console;
|
||||||
//char error[255] = "error!";
|
//char error[255] = "error!";
|
||||||
sys_pause = 1;
|
sys_pause = 1;
|
||||||
@ -3674,6 +3680,9 @@ int main(int argc, char *argv[])
|
|||||||
free(console);
|
free(console);
|
||||||
if(!console_mode)
|
if(!console_mode)
|
||||||
hud_enable = 1;
|
hud_enable = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
console_mode=0;
|
||||||
#else
|
#else
|
||||||
console_mode=0;
|
console_mode=0;
|
||||||
#endif
|
#endif
|
||||||
@ -3681,18 +3690,19 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
//execute python step hook
|
//execute python step hook
|
||||||
#ifdef PYCONSOLE
|
#ifdef PYCONSOLE
|
||||||
if(pstep!=NULL)
|
if(pyready==1)
|
||||||
{
|
if(pstep!=NULL)
|
||||||
pargs=Py_BuildValue("()");
|
{
|
||||||
pvalue = PyObject_CallObject(pstep, pargs);
|
pargs=Py_BuildValue("()");
|
||||||
Py_DECREF(pargs);
|
pvalue = PyObject_CallObject(pstep, pargs);
|
||||||
pargs=NULL;
|
Py_DECREF(pargs);
|
||||||
if(pvalue==NULL)
|
pargs=NULL;
|
||||||
strcpy(console_error,"failed to execute step code.");
|
if(pvalue==NULL)
|
||||||
//Py_DECREF(pvalue);
|
strcpy(console_error,"failed to execute step code.");
|
||||||
//puts("a");
|
//Py_DECREF(pvalue);
|
||||||
pvalue=NULL;
|
//puts("a");
|
||||||
}
|
pvalue=NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
|
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ if(DEBUG==False):
|
|||||||
sys.stdout=logger()
|
sys.stdout=logger()
|
||||||
sys.stderr=logger()
|
sys.stderr=logger()
|
||||||
|
|
||||||
|
|
||||||
element={"none":0,"dust":1,"watr":2,"oil":3,"fire":4,"stne":5,"lava":6,"gunp":7,
|
element={"none":0,"dust":1,"watr":2,"oil":3,"fire":4,"stne":5,"lava":6,"gunp":7,
|
||||||
"nitr":8,"clne":9,"gas":10,"plex":11,"goo":12,"icei":13,"metl":14,"sprk":15,
|
"nitr":8,"clne":9,"gas":10,"plex":11,"goo":12,"icei":13,"metl":14,"sprk":15,
|
||||||
"snow":16,"wood":17,"neut":18,"plut":19,"plnt":20,"acid":21,"void":22,
|
"snow":16,"wood":17,"neut":18,"plut":19,"plnt":20,"acid":21,"void":22,
|
||||||
|
Loading…
Reference in New Issue
Block a user