kojikamid: write buildrequires files as bytes

Fix a TypeError when downloading buildrequires files on Python 3.
base64.b64decode() returns bytes, so we must open the file for writing
in bytes mode, not text mode.

Add a unit test that verifies this behavior.
This commit is contained in:
Ken Dreyer 2022-11-09 10:41:15 -05:00
parent 56cea9adc2
commit 64a856f62b
3 changed files with 66 additions and 1 deletions

View file

@ -335,7 +335,7 @@ class WindowsBuild(object):
raise BuildError('Unknown checksum type %s for %s' % ( # noqa: F821
checksum_type,
os.path.basename(fileinfo['localpath'])))
with koji._open_text_file(destpath, 'wt') as destfile:
with open(destpath, 'wb') as destfile:
offset = 0
while True:
encoded = self.server.getFile(buildinfo, fileinfo, encode_int(offset), 1048576,