Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/python/cpython/src/patches/06-platform.patch
1067 views
1
The patch below changes the behavior of the platform module slightly to not
2
use uname -p on the host, in the case of wasm32, since that makes
3
no sense for our use case. Also, we change the corresponding unit test as well.
4
5
--- native/Lib/platform.py 2022-08-05 07:45:18.000000000 -0700
6
+++ wasm/Lib/platform.py 2022-09-12 20:53:45.000000000 -0700
7
@@ -663,6 +663,9 @@
8
binary defaults from _default_architecture are used.
9
10
"""
11
+ # the bitiness is the *size of a pointer*, which is 32-bit on WASM;
12
+ # analyzing binaries on host system isn't robust so we hardcode this.
13
+ return ("32bit", linkage)
14
# Use the sizeof(pointer) as default number of bits if nothing
15
# else is given as default.
16
if not bits:
17
@@ -753,6 +756,10 @@
18
"""
19
Fall back to `uname -p`
20
"""
21
+ # Special case for WASM where on nodejs we do NOT
22
+ # want to get the host processor.
23
+ return "wasm32"
24
+
25
try:
26
import subprocess
27
except ImportError:
28
29
--- native/Lib/test/test_platform.py 2022-08-05 07:45:18.000000000 -0700
30
+++ wasm/Lib/test/test_platform.py 2022-09-15 22:50:06.000000000 -0700
31
@@ -269,7 +269,7 @@
32
self.assertEqual(res[:], expected)
33
self.assertEqual(res[:5], expected[:5])
34
35
- @unittest.skipIf(sys.platform in ['win32', 'OpenVMS'], "uname -p not used")
36
+ @unittest.skipIf(sys.platform in ['wasi', 'win32', 'OpenVMS'], "uname -p not used")
37
@support.requires_subprocess()
38
def test_uname_processor(self):
39
"""
40
41