1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-08-11 17:54:06 +02:00

Use with statement in ArFile.saveTo

This makes sure that the file is closed in case of an exception.
This commit is contained in:
Marcus Huewe
2019-01-15 17:15:21 +01:00
parent b26a4a967d
commit 5c19425c9b

View File

@@ -74,9 +74,8 @@ class ArFile(BytesIO):
if not dir:
dir = os.getcwd()
fn = os.path.join(dir, self.name)
f = open(fn, 'wb')
f.write(self.getvalue())
f.close()
with open(fn, 'wb') as f:
f.write(self.getvalue())
os.chmod(fn, self.mode)
uid = self.uid
if uid != os.geteuid() or os.geteuid() != 0: