Prefer subprocess.DEVNULL over open(os.devnull, 'w')

Available since Python 3.3.

https://docs.python.org/3/library/subprocess.html#subprocess.DEVNULL

Use a context manager for the other opened file, dump.
This commit is contained in:
Jon Dufresne 2020-12-26 07:17:39 -08:00
parent 609d9d4a68
commit 50517b2171
2 changed files with 6 additions and 9 deletions

View File

@ -22,15 +22,12 @@ def _create_svn_initools_repo(initools_dir):
'http://bitbucket.org/hltbra/pip-initools-dump/raw/8b55c908a320/'
'INITools_modified.dump'
)
devnull = open(os.devnull, 'w')
dump = open(filename)
subprocess.check_call(
['svnadmin', 'load', initools_dir],
stdin=dump,
stdout=devnull,
)
dump.close()
devnull.close()
with open(filename) as dump:
subprocess.check_call(
['svnadmin', 'load', initools_dir],
stdin=dump,
stdout=subprocess.DEVNULL,
)
os.remove(filename)