]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127503 Don't propagate native PATH to Emscripten Python (#127633)
authorHood Chatham <roberthoodchatham@gmail.com>
Mon, 9 Dec 2024 02:01:37 +0000 (03:01 +0100)
committerGitHub <noreply@github.com>
Mon, 9 Dec 2024 02:01:37 +0000 (10:01 +0800)
Modifies the handling of PATH to ensure that native executables aren't picked
up when running under node.

Tools/wasm/emscripten/node_entry.mjs

index 40ab1515cf28c113be43651b1e11aaad4bd7d60c..98b8f572a7e7624fb2f8d6ceb2c3cd4aee503aa1 100644 (file)
@@ -35,11 +35,12 @@ const settings = {
     mountDirectories(Module);
     Module.FS.chdir(process.cwd());
     Object.assign(Module.ENV, process.env);
+    delete Module.ENV.PATH;
   },
   // Ensure that sys.executable, sys._base_executable, etc point to python.sh
   // not to this file. To properly handle symlinks, python.sh needs to compute
   // its own path.
-  thisProgram: process.argv[thisProgramIndex],
+  thisProgram: process.argv[thisProgramIndex].slice(thisProgram.length),
   // After python.sh come the arguments thatthe user passed to python.sh.
   arguments: process.argv.slice(thisProgramIndex + 1),
 };