diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2025-07-16 16:12:36 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-16 16:12:36 (GMT) |
| commit | 4eee754091eb1f4cf0d989d5d780ca8da45bb0ed (patch) | |
| tree | 4817c9d8c3f92d7e7ca06894ae9256a9e4f8b30e /Python | |
| parent | ca6db4fdae9e2a7369502218b46b03c2624a0836 (diff) | |
| download | cpython-4eee754091eb1f4cf0d989d5d780ca8da45bb0ed.zip cpython-4eee754091eb1f4cf0d989d5d780ca8da45bb0ed.tar.gz cpython-4eee754091eb1f4cf0d989d5d780ca8da45bb0ed.tar.bz2 | |
[3.14] gh-127146: Emscripten: Make os.umask() actually work (GH-136706) (#136711)
Provide a stub implementation of umask that is enough to get some tests passing.
More work is needed upstream in Emscripten to make all umask tests to pass.
(cherry picked from commit 12e52cad718723636a96042f9399634392285c44)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/emscripten_syscalls.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Python/emscripten_syscalls.c b/Python/emscripten_syscalls.c index 7875bfc..bb80f97 100644 --- a/Python/emscripten_syscalls.c +++ b/Python/emscripten_syscalls.c @@ -7,7 +7,7 @@ // defined with weak linkage so we can override it. EM_JS(int, __syscall_getuid32_js, (void), { // If we're in node and we can, report the native uid - if (typeof process !== "undefined" && typeof process.getuid === "function") { + if (ENVIRONMENT_IS_NODE) { return process.getuid(); } // Fall back to the stub case of returning 0. @@ -17,3 +17,23 @@ EM_JS(int, __syscall_getuid32_js, (void), { int __syscall_getuid32(void) { return __syscall_getuid32_js(); } + +EM_JS(int, __syscall_umask_js, (int mask), { + // If we're in node and we can, call native process.umask() + if (ENVIRONMENT_IS_NODE) { + try { + return process.umask(mask); + } catch(e) { + // oops... + // NodeJS docs: "In Worker threads, process.umask(mask) will throw an exception." + // umask docs: "This system call always succeeds" + return 0; + } + } + // Fall back to the stub case of returning 0. + return 0; +}) + +int __syscall_umask(int mask) { + return __syscall_umask_js(mask); +} |
