Skip to content

Commit

Permalink
fix #52
Browse files Browse the repository at this point in the history
If PyStand.exe is attached to a console, then show error message in the console.
  • Loading branch information
myd7349 committed Jul 20, 2023
1 parent cf2e5e3 commit 96d7042
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PyStand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@ const char *init_script =
" fp = os.fdopen(fd, 'w')\n"
" sys.stdout = fp\n"
" sys.stderr = fp\n"
" attached = True\n"
"except Exception as e:\n"
" fp = open(os.devnull, 'w')\n"
" sys.stdout = fp\n"
" sys.stderr = fp\n"
" attached = False\n"
#endif
"for n in ['.', 'lib', 'site-packages']:\n"
" test = os.path.abspath(os.path.join(PYSTAND_HOME, n))\n"
Expand All @@ -359,6 +361,8 @@ const char *init_script =
" code = compile(text, PYSTAND_SCRIPT, 'exec')\n"
" exec(code, environ)\n"
"except Exception:\n"
" if attached:\n"
" raise\n"
" import traceback, io\n"
" sio = io.StringIO()\n"
" traceback.print_exc(file = sio)\n"
Expand Down

0 comments on commit 96d7042

Please sign in to comment.