| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2e30cbf commit ee8a4e7
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,8 +77,9 @@ def check_trace_presence(bootstrap, mode): | |||
| 77 | 77 | codes = { | |
| 78 | 78 | bootstrap._exec.__code__, | |
| 79 | 79 | bootstrap._load_unlocked.__code__, | |
| 80 | - bootstrap._load_backward_compatible.__code__, | ||
| 81 | 80 | } | |
| 81 | + if hasattr(bootstrap, "_load_backward_compatible"): | ||
| 82 | + codes.add(bootstrap._load_backward_compatible.__code__) | ||
| 82 | 83 | if hasattr(bootstrap, "_reorder_module"): | |
| 83 | 84 | codes.add(bootstrap._reorder_module.__code__) | |
| 84 | 85 | ||
@@ -185,16 +186,20 @@ def fail_with_entry(module): | |||
| 185 | 186 | ) | |
| 186 | 187 | assert list(sys.modules)[-2:] == [after, name] | |
| 187 | 188 | ||
| 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"): | ||
| 193 | 190 | ||
| 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 | ||
| 198 | 203 | finally: | |
| 199 | 204 | sys.modules = original | |
| 200 | 205 | ||
@@ -445,7 +450,10 @@ def __del__(self): | |||
| 445 | 450 | if sys.implementation.name == "rustpython": | |
| 446 | 451 | # Run this before inspecting the new helper so a baseline executable | |
| 447 | 452 | # 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: | ||
| 449 | 457 | check_trace_presence(bootstrap, mode) | |
| 450 | 458 | check_loader_semantics(bootstrap) | |
| 451 | 459 | if hasattr(bootstrap, "_reorder_module"): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments