mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] GH-115979: update test_importlib to work under WASI SDK 21 (GH-116754) (GH-116759)
GH-115979: update test_importlib to work under WASI SDK 21 (GH-116754)
(cherry picked from commit 61733a2fb9
)
Co-authored-by: Brett Cannon <brett@python.org>
This commit is contained in:
parent
592c0e26c0
commit
0cc504771f
8 changed files with 44 additions and 27 deletions
|
@ -6,6 +6,7 @@ from importlib import machinery, util, invalidate_caches
|
|||
import marshal
|
||||
import os
|
||||
import os.path
|
||||
from test import support
|
||||
from test.support import import_helper
|
||||
from test.support import os_helper
|
||||
import unittest
|
||||
|
@ -22,25 +23,34 @@ if 'errno' in sys.builtin_module_names:
|
|||
if 'importlib' not in sys.builtin_module_names:
|
||||
BUILTINS.bad_name = 'importlib'
|
||||
|
||||
EXTENSIONS = types.SimpleNamespace()
|
||||
EXTENSIONS.path = None
|
||||
EXTENSIONS.ext = None
|
||||
EXTENSIONS.filename = None
|
||||
EXTENSIONS.file_path = None
|
||||
EXTENSIONS.name = '_testsinglephase'
|
||||
if support.is_wasi:
|
||||
# dlopen() is a shim for WASI as of WASI SDK which fails by default.
|
||||
# We don't provide an implementation, so tests will fail.
|
||||
# But we also don't want to turn off dynamic loading for those that provide
|
||||
# a working implementation.
|
||||
def _extension_details():
|
||||
global EXTENSIONS
|
||||
EXTENSIONS = None
|
||||
else:
|
||||
EXTENSIONS = types.SimpleNamespace()
|
||||
EXTENSIONS.path = None
|
||||
EXTENSIONS.ext = None
|
||||
EXTENSIONS.filename = None
|
||||
EXTENSIONS.file_path = None
|
||||
EXTENSIONS.name = '_testsinglephase'
|
||||
|
||||
def _extension_details():
|
||||
global EXTENSIONS
|
||||
for path in sys.path:
|
||||
for ext in machinery.EXTENSION_SUFFIXES:
|
||||
filename = EXTENSIONS.name + ext
|
||||
file_path = os.path.join(path, filename)
|
||||
if os.path.exists(file_path):
|
||||
EXTENSIONS.path = path
|
||||
EXTENSIONS.ext = ext
|
||||
EXTENSIONS.filename = filename
|
||||
EXTENSIONS.file_path = file_path
|
||||
return
|
||||
def _extension_details():
|
||||
global EXTENSIONS
|
||||
for path in sys.path:
|
||||
for ext in machinery.EXTENSION_SUFFIXES:
|
||||
filename = EXTENSIONS.name + ext
|
||||
file_path = os.path.join(path, filename)
|
||||
if os.path.exists(file_path):
|
||||
EXTENSIONS.path = path
|
||||
EXTENSIONS.ext = ext
|
||||
EXTENSIONS.filename = filename
|
||||
EXTENSIONS.file_path = file_path
|
||||
return
|
||||
|
||||
_extension_details()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue