Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
loader: disable import tracing if sys.stderr is unavailable (#5477)
The `FrozenImporter` in `pymod03_importers` uses `trace()` function if `sys.flags.verbose` is enabled to trace the imports to `sys.stderr`. This results in the following error: `Failed to execute script pyiboot01_bootstrap` when `sys.stderr` is unavailable (is `None`), which happens on Windows when windowed bootloader is used in combination with `sys.flags.verbose` enabled (i.e., `--debug imports` or `--debug all` is passed on the command-line). The problem is that while `pyiboot01_bootstrap` does install its `NullWriter` for `sys.stderr` when the latter is unavailable, that happens too late; there is an `import os` that happens between the end of bootstrap process (the `pyimod03_importers.install()` call) and monkey-patching `NullWriter()` into `sys.stderr`. While the problem could also be fixed by moving the `NullWriter` initialization before the offending import, simply disabling the `trace()` function seems a better option. Fixes #4213.
- Loading branch information