1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

Avoid a potential TypeError in util.ArFile.saveTo

If no dir is passed to util.ArFile.saveTo, dir is set to os.getcwd(),
which returns a str. Since self.name is a bytes, the subsequent
os.path.join(dir, self.name) results in a TypeError.
To fix this, use os.getcwdb(), which returns a bytes instead of a
str.
This commit is contained in:
Marcus Huewe 2020-11-22 17:36:17 +01:00
parent 926c2eb422
commit 674ea78815

View File

@ -72,7 +72,7 @@ class ArFile(BytesIO):
and permissions.
"""
if not dir:
dir = os.getcwd()
dir = os.getcwdb()
fn = os.path.join(dir, self.name)
with open(fn, 'wb') as f:
f.write(self.getvalue())