Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loader: disable import tracing if sys.stderr is unavailable #5477

Merged
merged 1 commit into from
Jan 28, 2021

Commits on Jan 17, 2021

  1. loader: disable import tracing if sys.stderr is unavailable

    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 pyinstaller#4213.
    rokm committed Jan 17, 2021
    Configuration menu
    Copy the full SHA
    e724adb View commit details
    Browse the repository at this point in the history