[PATCH] D79326: [clang-format] ensure dump_format_style.py works with Python3 correctly
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 4 06:22:28 PDT 2020
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, mitchell-stellar, sammccall, owenpan.
MyDeveloperDay added projects: clang, clang-format.
Python2 has been removed from cygwin, this means anyone running the dump_format_style.py in a cygwin shell could pick up python3 instead
In Python3 all strings are unicode as the file is opened in binary mode we need to encode the contents string or we'll face the following error
Traceback (most recent call last):
File "./dump_format_style.py", line 228, in <module>
output.write(contents)
TypeError: a bytes-like object is required, not 'str'
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79326
Files:
clang/docs/tools/dump_format_style.py
Index: clang/docs/tools/dump_format_style.py
===================================================================
--- clang/docs/tools/dump_format_style.py
+++ clang/docs/tools/dump_format_style.py
@@ -225,4 +225,4 @@
contents = substitute(contents, 'FORMAT_STYLE_OPTIONS', options_text)
with open(DOC_FILE, 'wb') as output:
- output.write(contents)
+ output.write(contents.encode())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79326.261797.patch
Type: text/x-patch
Size: 389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200504/ac42bf5a/attachment.bin>
More information about the cfe-commits
mailing list