GeezerVison is showing github.com — gh-127503: Improve tracebacks on Emscripten when there is a trap · python/cpython@f173d1f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Tools/wasm/emscripten/node_entry.mjs +14-1Lines changed: 14 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,11 +32,16 @@ const thisProgramIndex = process.argv.findIndex((x) => | 32 | 32 |
| 33 | 33 | const settings = { | 34 | 34 | preRun(Module) { | | 35 | + // Globally expose API object so we can access it if we raise on startup. | | 36 | + globalThis.Module = Module; | 35 | 37 | mountDirectories(Module); | 36 | 38 | Module.FS.chdir(process.cwd()); | 37 | 39 | Object.assign(Module.ENV, process.env); | 38 | 40 | delete Module.ENV.PATH; | 39 | 41 | }, | | 42 | + onExit(x) { | | 43 | + console.log("onExit", ...arguments); | | 44 | + }, | 40 | 45 | // Ensure that sys.executable, sys._base_executable, etc point to python.sh | 41 | 46 | // not to this file. To properly handle symlinks, python.sh needs to compute | 42 | 47 | // its own path. | @@ -45,4 +50,12 @@ const settings = { | 45 | 50 | arguments: process.argv.slice(thisProgramIndex + 1), | 46 | 51 | }; | 47 | 52 |
| 48 | | -await EmscriptenModule(settings); | | 53 | +try { | | 54 | + await EmscriptenModule(settings); | | 55 | +} catch(e) { | | 56 | + // Show JavaScript exception and traceback | | 57 | + console.warn(e); | | 58 | + // Show Python exception and traceback | | 59 | + Module.__Py_DumpTraceback(2, Module._PyGILState_GetThisThreadState()); | | 60 | + process.exit(1); | | 61 | +} |
Collapse file Copy file name to clipboardExpand all lines: configure +1-1Lines changed: 1 addition & 1 deletion Collapse file Copy file name to clipboardExpand all lines: configure.ac +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2370,7 +2370,7 @@ AS_CASE([$ac_sys_system], | 2370 | 2370 | dnl Include file system support | 2371 | 2371 | AS_VAR_APPEND([LINKFORSHARED], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"]) | 2372 | 2372 | AS_VAR_APPEND([LINKFORSHARED], [" -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV"]) | 2373 | | - AS_VAR_APPEND([LINKFORSHARED], [" -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET"]) | | 2373 | + AS_VAR_APPEND([LINKFORSHARED], [" -sEXPORTED_FUNCTIONS=_main,_Py_Version,__PyRuntime,__PyEM_EMSCRIPTEN_COUNT_ARGS_OFFSET,_PyGILState_GetThisThreadState,__Py_DumpTraceback"]) | 2374 | 2374 | AS_VAR_APPEND([LINKFORSHARED], [" -sSTACK_SIZE=5MB"]) | 2375 | 2375 |
| 2376 | 2376 | AS_VAR_IF([enable_wasm_dynamic_linking], [yes], [ | |
|