From 57c93181b1e4aaef2891080cb5e95f7b5a271746 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 10 Dec 2020 16:19:24 +0100 Subject: [PATCH] Fix unsupported operand type(s) for %: 'bytes' and 'bytes' This fix also avoid empty file generation on headers lines generation errors. --- check_slapdd_crc32 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/check_slapdd_crc32 b/check_slapdd_crc32 index 8187b02..3426b53 100755 --- a/check_slapdd_crc32 +++ b/check_slapdd_crc32 @@ -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)