From 12db6bbe3712042c10383082a4c40702b800a36a Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Fri, 10 Feb 2017 13:31:41 +0100 Subject: [PATCH] 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'))) --- git/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/cmd.py b/git/cmd.py index 245a7f609..a4d4c323a 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -580,7 +580,7 @@ def execute(self, command, stdout_sink = (PIPE if with_stdout - else getattr(subprocess, 'DEVNULL', open(os.devnull, 'wb'))) + else getattr(subprocess, 'DEVNULL', None) or open(os.devnull, 'wb')) log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s)", command, cwd, universal_newlines, shell) try: