pythonrun by youknowone · Pull Request #6643 · RustPython/RustPython
52-52: LGTM: Imports align with new functionality.
The added imports support the new execution helpers and updated VM APIs.
147-147: LGTM: API update applied correctly.
The change from run_code_string to run_string is consistent with the new VM API.
176-183: Past review concern addressed.
The code now uses .and_then(|p| p.to_str()).unwrap_or("") which safely handles edge cases where parent() returns None (root paths) or to_str() fails (non-UTF-8 paths). This matches the previously suggested fix.
256-256: LGTM: API update applied correctly.
The change from run_code_string to run_simple_string is appropriate for this simple one-liner initialization.
279-279: LGTM: API update applied correctly.
The change to run_string is consistent with the new VM API.
287-290: LGTM: Script execution now uses the new helper.
The delegation to run_file properly handles both package/directory and regular file execution, matching CPython's pymain_run_file_obj behavior.
371-375: LGTM: Tests validate both execution modes.
The tests appropriately verify direct file execution and directory module execution with __main__.py, covering the new run_file functionality.
188-217: sys.path_hooks is already properly initialized during VM startup.
The code does not rely on site.py (which doesn't exist in this repository) to populate path_hooks. Instead, initialization happens automatically in init_importlib_package during VM construction, where importlib._install_external_importers() is called and zipimporter is registered as the first path hook. This occurs before any user code—including get_importer—is executed. Additionally, get_importer safely handles empty path hooks by falling back to vm.run_any_file.
Likely an incorrect or invalid review comment.