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/' 'http://bitbucket.org/hltbra/pip-initools-dump/raw/8b55c908a320/'
'INITools_modified.dump' 'INITools_modified.dump'
) )
devnull = open(os.devnull, 'w') with open(filename) as dump:
dump = open(filename) subprocess.check_call(
subprocess.check_call( ['svnadmin', 'load', initools_dir],
['svnadmin', 'load', initools_dir], stdin=dump,
stdin=dump, stdout=subprocess.DEVNULL,
stdout=devnull, )
)
dump.close()
devnull.close()
os.remove(filename) os.remove(filename)