Fix test_import: import machinery, circular imports, and script shadowing#7034
Fix test_import: import machinery, circular imports, and script shadowing#7034youknowone wants to merge 7 commits intoRustPython:mainfrom
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Code has been automatically formatted The code in this PR has been formatted using:
git pull origin test_import |
133d65e to
dc0f0b7
Compare
…wing - Emit IMPORT_FROM instead of LOAD_ATTR for `import a.b.c as m` (compile.rs) - Add "partially initialized module" error in module getattr for circular imports - Add "cannot access submodule" error for initializing submodules - Implement "consider renaming" script shadowing detection (module.rs, frame.rs) - Detect when a user script shadows a stdlib or third-party module - Compute original sys.path[0] from sys.argv[0] (like CPython's config->sys_path_0) - Check sys.stdlib_module_names for stdlib module detection - Respect safe_path setting - Implement _imp._fix_co_filename to rewrite code object source_path in-place - Add data parameter support to _imp.get_frozen_object with marshal deserialization - Fix import_from error messages: check __spec__.has_location before using origin - Set ImportError.path attribute on import failures - Fix import_star error messages for non-str items in __all__ and __dict__ - Always call builtins.__import__ (remove sys.modules cache bypass in import_inner)
0c03ef7 to
3bcc98b
Compare
…egistration
- Look up encoding submodules in sys.modules after import, since
__import__("encodings.ascii") returns the top-level "encodings" package
- Remove @expectedfailure from test_frozen_submodule_in_unfrozen_package
and test_unfrozen_submodule_in_frozen_package (now passing)
- Add __hello_only__.py frozen module source (was untracked)
7566ba8 to
5c6b68b
Compare
…indows-only tests - Use to_str() instead of as_str() in import_module_level and get_spec_origin to avoid panic on strings with surrogates - Add @expectedfailure for test_dll_dependency_import (no C extension), test_unencodable_filename (subprocess), test_tagged_suffix (no .pyd)
124b7ac to
d4bf285
Compare
…lookup Change import_module_level signature from &PyStr to &Py<PyStr> to enable direct DictKey usage for sys.modules lookup. When module name contains surrogates (e.g. from Windows unencodable filenames), fall back to sys.modules lookup using the original Python string key, preserving surrogates for correct hash/equality matching.
normalize_encoding_name maps "utf-8" to "utf_8" but leaves "utf8" as-is,
so codecs.lookup("utf8") misses the cache when only "utf_8" is registered.
The full encodings.search_function handles this via aliases, but register
the common "utf8" alias during bootstrap as a safety net.
1f78b06 to
294d609
Compare
f7f4e0d to
8e26d76
Compare
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: (module 'hello_only' not found) [ ] lib: cpython/Lib/argparse.py dependencies:
dependent tests: (3 tests)
[ ] lib: cpython/Lib/configparser.py dependencies:
dependent tests: (2 tests)
[ ] lib: cpython/Lib/dataclasses.py dependencies:
dependent tests: (6 tests)
[ ] lib: cpython/Lib/difflib.py dependencies:
dependent tests: (4 tests)
[ ] lib: cpython/Lib/getopt.py dependencies:
dependent tests: (1 tests)
[ ] lib: cpython/Lib/getpass.py dependencies:
dependent tests: (1 tests)
[ ] lib: cpython/Lib/inspect.py dependencies:
dependent tests: (41 tests)
[ ] test: cpython/Lib/test/test___all__.py (TODO: 1) dependencies: dependent tests: (no tests depend on all) [ ] test: cpython/Lib/test/test_binop.py dependencies: dependent tests: (no tests depend on binop) [ ] test: cpython/Lib/test/test_contains.py dependencies: dependent tests: (no tests depend on contains) [x] test: cpython/Lib/test/test_dict.py (TODO: 6) dependencies: dependent tests: (no tests depend on dict) [x] test: cpython/Lib/test/test_exceptions.py (TODO: 25) dependencies: dependent tests: (no tests depend on exception) [x] test: cpython/Lib/test/test_frozen.py dependencies: dependent tests: (no tests depend on frozen) [ ] test: cpython/Lib/test/test_import (TODO: 3) dependencies: dependent tests: (no tests depend on import) [x] lib: cpython/Lib/importlib dependencies:
dependent tests: (66 tests)
[x] lib: cpython/Lib/pickle.py dependencies:
dependent tests: (70 tests)
[x] lib: cpython/Lib/reprlib.py dependencies:
dependent tests: (162 tests)
[ ] test: cpython/Lib/test/test_sort.py (TODO: 2) dependencies: dependent tests: (no tests depend on sort) [x] lib: cpython/Lib/threading.py dependencies:
dependent tests: (109 tests)
[ ] lib: cpython/Lib/tomllib dependencies:
dependent tests: (no tests depend on tomllib) [x] test: cpython/Lib/test/test_list.py (TODO: 5) dependencies: dependent tests: (no tests depend on list) Legend:
|
import a.b.c as m(compile.rs)