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:
@@ -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:
|
||||
|
Reference in New Issue
Block a user