Skip to content

Commit

Permalink
Always close stderr after subprocess completion in call_subprocess()
Browse files Browse the repository at this point in the history
When running Python with warnings enabled, fixes warnings of the form:

    .../site-packages/pip/_internal/vcs/versioncontrol.py:773: ResourceWarning: unclosed file <_io.BufferedReader name=12>
      return call_subprocess(cmd, cwd,
  • Loading branch information
jdufresne committed Nov 21, 2020
1 parent 396afb1 commit 8662248
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/9156.bugfix.rst
@@ -0,0 +1 @@
Fix ResourceWarning in VCS subprocesses
2 changes: 2 additions & 0 deletions src/pip/_internal/vcs/versioncontrol.py
Expand Up @@ -150,6 +150,8 @@ def call_subprocess(
finally:
if proc.stdout:
proc.stdout.close()
if proc.stderr:
proc.stderr.close()

proc_had_error = (
proc.returncode and proc.returncode not in extra_ok_returncodes
Expand Down

0 comments on commit 8662248

Please sign in to comment.