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

Importing freeze requires an attached stdin #7042

Closed
y2kbugger opened this issue Sep 19, 2019 · 3 comments
Closed

Importing freeze requires an attached stdin #7042

y2kbugger opened this issue Sep 19, 2019 · 3 comments
Labels
auto-locked Outdated issues that have been locked by automation type: support User Support

Comments

@y2kbugger
Copy link

y2kbugger commented Sep 19, 2019

Environment

  • pip version: 19.2.2
  • Python version: 3.6.9
  • OS: Windows

Flask on IIS using wfastcgi. https://pypi.org/project/wfastcgi/
WFastCGI runs the WSGI handler with stdin detached.

Description
pip checks state of stdin without checking whether it is attached first.

See #7034

Expected behavior

No unhandled exception.

How to Reproduce

Specifically the error occurs when you detach stdin:

import sys
sys.stdin.detach()
from pip._internal.operations import freeze

Output

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\main_parser.py", line 11, in <module>
    from pip._internal.commands import (
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\commands\__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\commands\completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 21, in <module>
    from pip._internal.download import PipSession
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\download.py", line 47, in <module>
    from pip._internal.vcs import vcs
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\vcs\__init__.py", line 12, in <module>
    import pip._internal.vcs.subversion  # noqa: F401
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\vcs\subversion.py", line 314, in <module>
    vcs.register(Subversion)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\vcs\versioncontrol.py", line 165, in register
    self._registry[cls.name] = cls()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\vcs\subversion.py", line 180, in __init__
    use_interactive = sys.stdin.isatty()
ValueError: underlying buffer has been detached
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Sep 19, 2019
@chrahunt
Copy link
Member

I feel obliged to say that importing and running pip internal functions is not supported, and running pip freeze in a subprocess probably wouldn't suffer from this. Unless we can demonstrate pip misbehaving when invoked as a separate process, I think this will not go far.

That said, (legitimate) issue #2920 will need a function written to tell whether we were invoked interactively (sys.stdout.isatty() and sys.stdin.isatty()). If whoever was fixing that issue happened to check whether both streams were not detached (to avoid throwing a ValueError) and also happened to use that function for setting use_interactive here, it would probably be OK.

Let's hope whoever fixes that issue does that! :)

@chrahunt chrahunt added S: awaiting response Waiting for a response/more information type: support User Support labels Sep 19, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Sep 19, 2019
@cjerdonek
Copy link
Member

If pip's code doesn't call detach(), it doesn't seem like pip should have code to make sure detach() hasn't been called, IMO.

@no-response
Copy link

no-response bot commented Oct 20, 2019

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Oct 20, 2019
@pradyunsg pradyunsg removed the S: awaiting response Waiting for a response/more information label Oct 20, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Nov 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: support User Support
Projects
None yet
Development

No branches or pull requests

4 participants