FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Keep atomic import regression compatible with modern bootstrap · RustPython/RustPython@ee8a4e7 · GitHub

Repository navigation

Commit ee8a4e7

Browse files
committed
Keep atomic import regression compatible with modern bootstrap
Run legacy-loader cases when the bootstrap exposes that helper, preserving all four 3.14 paths and the two remaining 3.15 paths. Always retain modern load and exec regressions. Assisted-by: Codex:model-version-unavailable
1 parent 2e30cbf commit ee8a4e7

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

‎extra_tests/snippets/import_atomic_reorder.py‎

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ def check_trace_presence(bootstrap, mode):
7777
codes = {
7878
bootstrap._exec.__code__,
7979
bootstrap._load_unlocked.__code__,
80-
bootstrap._load_backward_compatible.__code__,
8180
}
81+
if hasattr(bootstrap, "_load_backward_compatible"):
82+
codes.add(bootstrap._load_backward_compatible.__code__)
8283
if hasattr(bootstrap, "_reorder_module"):
8384
codes.add(bootstrap._reorder_module.__code__)
8485

@@ -185,16 +186,20 @@ def fail_with_entry(module):
185186
)
186187
assert list(sys.modules)[-2:] == [after, name]
187188

188-
class LegacyLoader:
189-
def load_module(self, fullname):
190-
sys.modules[fullname] = None
191-
del sys.modules[fullname]
192-
raise failure
189+
if hasattr(bootstrap, "_load_backward_compatible"):
193190

194-
spec = bootstrap.ModuleSpec(name, LegacyLoader())
195-
sys.modules = original.copy()
196-
raises(RuntimeError, lambda: bootstrap._load_backward_compatible(spec), failure)
197-
assert name not in sys.modules
191+
class LegacyLoader:
192+
def load_module(self, fullname):
193+
sys.modules[fullname] = None
194+
del sys.modules[fullname]
195+
raise failure
196+
197+
spec = bootstrap.ModuleSpec(name, LegacyLoader())
198+
sys.modules = original.copy()
199+
raises(
200+
RuntimeError, lambda: bootstrap._load_backward_compatible(spec), failure
201+
)
202+
assert name not in sys.modules
198203
finally:
199204
sys.modules = original
200205

@@ -445,7 +450,10 @@ def __del__(self):
445450
if sys.implementation.name == "rustpython":
446451
# Run this before inspecting the new helper so a baseline executable
447452
# fails on the actual pop/set gap, not just a missing private API.
448-
for mode in ("load", "exec", "legacy", "legacy_error"):
453+
modes = ("load", "exec")
454+
if hasattr(bootstrap, "_load_backward_compatible"):
455+
modes += ("legacy", "legacy_error")
456+
for mode in modes:
449457
check_trace_presence(bootstrap, mode)
450458
check_loader_semantics(bootstrap)
451459
if hasattr(bootstrap, "_reorder_module"):

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL