Deepfreeze essential parts of the encodings module. ### Description

This is a split off from #3582.

Deepfreeze essential parts of encodings module (encodings.\__init__, encodings.utf_8, and encodings.aliases), which is required during the Python bootstrap.

From bb33672157df771613c9d6c61756c5294f13333d Mon Sep 17 00:00:00 2001
From: ryanking13 <def6488@gmail.com>
Date: Fri, 2 Dec 2022 11:36:44 +0000
Subject: [PATCH 3/8] Add emscripten platform support to
 ctypes.util.find_library

---
 Lib/ctypes/util.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 0c2510e161..c8875ec009 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -80,6 +80,30 @@ def find_library(name):
                 continue
         return None
 
+elif os.name == "posix" and sys.platform == "emscripten":
+    def _is_wasm(filename):
+        # Return True if the given file is an WASM module
+        wasm_header = b'\x00asm'
+        with open(filename, 'br') as thefile:
+            return thefile.read(4) == wasm_header
+
+    def find_library(name):
+        possible = ['lib%s.so' % name,
+                    'lib%s.wasm' % name]
+
+        paths = os.environ.get('LD_LIBRARY_PATH', '')
+        for dir in paths.split(":"):
+            for name in possible:
+                libfile = os.path.join(dir, name)
+
+                if os.path.isfile(libfile):
+                    if not _is_wasm(libfile):
+                        continue
+
+                    return libfile
+
+        return None
+
 elif sys.platform.startswith("aix"):
     # AIX has two styles of storing shared libraries
     # GNU auto_tools refer to these as svr4 and aix
-- 
2.29.2.windows.2


From bb33672157df771613c9d6c61756c5294f13333d Mon Sep 17 00:00:00 2001
From: ryanking13 <def6488@gmail.com>
Date: Fri, 2 Dec 2022 11:36:44 +0000
Subject: [PATCH 3/9] Add emscripten platform support to
 ctypes.util.find_library

---
 Lib/ctypes/util.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 0c2510e161..c8875ec009 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -80,6 +80,30 @@ def find_library(name):
                 continue
         return None
 
+elif os.name == "posix" and sys.platform == "emscripten":
+    def _is_wasm(filename):
+        # Return True if the given file is an WASM module
+        wasm_header = b'\x00asm'
+        with open(filename, 'br') as thefile:
+            return thefile.read(4) == wasm_header
+
+    def find_library(name):
+        possible = ['lib%s.so' % name,
+                    'lib%s.wasm' % name]
+
+        paths = os.environ.get('LD_LIBRARY_PATH', '')
+        for dir in paths.split(":"):
+            for name in possible:
+                libfile = os.path.join(dir, name)
+
+                if os.path.isfile(libfile):
+                    if not _is_wasm(libfile):
+                        continue
+
+                    return libfile
+
+        return None
+
 elif sys.platform.startswith("aix"):
     # AIX has two styles of storing shared libraries
     # GNU auto_tools refer to these as svr4 and aix
-- 
2.29.2.windows.2

