Fix unsupported operand type(s) for %: 'bytes' and 'bytes'

This fix also avoid empty file generation on headers lines generation errors.
This commit is contained in:
Benjamin Renard 2020-12-10 16:19:24 +01:00 committed by root
parent e241fc0571
commit 57c93181b1

View file

@ -131,9 +131,12 @@ def fix_crc32(path, crc32, lines):
if not options.fix:
return True
try:
headers_lines = [
b'# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.\n',
b'# CRC32 ' + crc32.encode() + b'\n',
]
with open(path, 'wb') as fd:
lines = [b'# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.\n', b'# CRC32 %s\n' % crc32.encode()] + lines
for line in lines:
for line in headers_lines + lines:
fd.write(line)
except IOError as err:
logging.error('%s: fail to write new file content (%s)', path, err)