diff options
author | Kim Gräsman <kim.grasman@gmail.com> | 2023-02-22 20:25:48 +0100 |
---|---|---|
committer | Kim Gräsman <kim.grasman@gmail.com> | 2023-02-23 21:10:23 +0100 |
commit | 06804f6b175704d81a34fc67ad8d59262509bf37 (patch) | |
tree | 198981c7165cb7e24ed4d51c30af813073639139 | |
parent | 435ad9d35ceee7759ea8f8fd658579e979ee5146 (diff) |
[iwyu-check-license-header] Write bytes, not str
This has apparently never been tested with python3; it fails because
write() expects bytes, not str.
Explicitly re-encode all content as utf-8, which is a reasonable
assumption for IWYU.
-rwxr-xr-x | iwyu-check-license-header.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/iwyu-check-license-header.py b/iwyu-check-license-header.py index 13f3a6e..711703e 100755 --- a/iwyu-check-license-header.py +++ b/iwyu-check-license-header.py @@ -161,9 +161,10 @@ class File(object): lines += after # Write back out + content = '\n'.join(lines) with open(self.filename, 'wb') as fd: - fd.write('\n'.join(lines)) - fd.write('\n') + fd.write(content.encode('utf-8')) + fd.write(b'\n') def check_license_header(self): """ Check that the header lines follow convention. |