Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/python/cpython/src/patches/05-st_mode.patch
1067 views
1
--- native/Modules/posixmodule.c 2022-08-05 07:45:18.000000000 -0700
2
+++ wasm/Modules/posixmodule.c 2022-09-07 09:53:36.000000000 -0700
3
@@ -2391,8 +2391,12 @@
4
PyObject *v = PyStructSequence_New((PyTypeObject *)StatResultType);
5
if (v == NULL)
6
return NULL;
7
-
8
- PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode));
9
+ // On WASM we modify st_mode to include u+rwx, since WASI provides nothing
10
+ // but "is it a directory or not" in st_mode, and this breaks a lot of things
11
+ // horribly, e.g., the entire zipfile module. For now the best solution is
12
+ // this patch. This will change -- see
13
+ // https://github.com/WebAssembly/wasi-filesystem/issues/34
14
+ PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode | 448));
15
static_assert(sizeof(unsigned long long) >= sizeof(st->st_ino),
16
"stat.st_ino is larger than unsigned long long");
17
PyStructSequence_SET_ITEM(v, 1, PyLong_FromUnsignedLongLong(st->st_ino));
18
19