Skip to content

Check for stdout/stderr in case file descriptor is closed#1620

Merged
dukecat0 merged 2 commits intopypa:mainfrom
julien-lecomte:jle-closed-stdout
Jun 13, 2025
Merged

Check for stdout/stderr in case file descriptor is closed#1620
dukecat0 merged 2 commits intopypa:mainfrom
julien-lecomte:jle-closed-stdout

Conversation

@julien-lecomte
Copy link
Contributor

Summary of changes

File descrptors may be closed when using pipx, such is a case when using the bash specific file redirections clauses >&- and/or "2&-`

Test plan

Before:

$ pipx install bumpversion2 >&-
Traceback (most recent call last):
  File "/home/julien/.local/bin/pipx", line 5, in <module>
    from pipx.main import cli
  File "/home/julien/.local/pipx/venvs/pipx/lib/python3.11/site-packages/pipx/main.py", line 22, in <module>
    from pipx import commands, constants, paths
  File "/home/julien/.local/pipx/venvs/pipx/lib/python3.11/site-packages/pipx/commands/__init__.py", line 3, in <module>
    from pipx.commands.inject import inject
  File "/home/julien/.local/pipx/venvs/pipx/lib/python3.11/site-packages/pipx/commands/inject.py", line 9, in <module>
    from pipx.colors import bold
  File "/home/julien/.local/pipx/venvs/pipx/lib/python3.11/site-packages/pipx/colors.py", line 9, in <module>
    PRINT_COLOR = sys.stdout.isatty()
                  ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'isatty'

@dukecat0 dukecat0 enabled auto-merge (squash) June 13, 2025 11:44
@dukecat0 dukecat0 disabled auto-merge June 13, 2025 12:10
@dukecat0 dukecat0 merged commit 33f37fc into pypa:main Jun 13, 2025
10 checks passed
@julien-lecomte julien-lecomte deleted the jle-closed-stdout branch June 13, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants