Always close stderr after subprocess completion in call_subprocess()

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,
This commit is contained in:
Jon Dufresne 2020-11-21 07:20:19 -08:00
parent 396afb118e
commit 8662248774
2 changed files with 3 additions and 0 deletions

1
news/9156.bugfix.rst Normal file
View File

@ -0,0 +1 @@
Fix ResourceWarning in VCS subprocesses

View File

@ -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