Skip to content

Commit 6171cd6

Browse files
author
skywind3000
committed
display traceback with a MessageBox in GUI mode
1 parent 4a66007 commit 6171cd6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

PyStand.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,17 @@ const char *init_script =
336336
"code = compile(text, PYSTAND_SCRIPT, 'exec')\n"
337337
"environ = {'__file__': PYSTAND_SCRIPT, '__name__': '__main__'}\n"
338338
"environ['__package__'] = None\n"
339+
#ifndef PYSTAND_CONSOLE
340+
"try:\n"
341+
" exec(code, environ)\n"
342+
"except:\n"
343+
" import traceback, io\n"
344+
" sio = io.StringIO()\n"
345+
" traceback.print_exc(file = sio)\n"
346+
" os.MessageBox(sio.getvalue(), 'Error')\n"
347+
#else
339348
"exec(code, environ)\n"
349+
#endif
340350
"";
341351

342352

0 commit comments

Comments
 (0)