Skip to content

Commit 12db6bb

Browse files
authored
fix(cmd): checking process.DEVNUL were needlessly opening os.devnull
Fixes resource-leak warning on Windows Puython-3.5.3+: D:\python-3.5.2.amd64\lib\site-packages\git\cmd.py:583: ResourceWarning: unclosed file <_io.BufferedWriter name='nul'> else getattr(subprocess, 'DEVNULL', open(os.devnull, 'wb')))
1 parent b197de0 commit 12db6bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎git/cmd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def execute(self, command,
580580

581581
stdout_sink = (PIPE
582582
if with_stdout
583-
else getattr(subprocess, 'DEVNULL', open(os.devnull, 'wb')))
583+
else getattr(subprocess, 'DEVNULL', None) or open(os.devnull, 'wb'))
584584
log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)",
585585
command, cwd, universal_newlines, shell)
586586
try:

0 commit comments

Comments
 (0)