[clang] 3125aa9 - [clang-format] ensure dump_format_style.py works with Python3 correctly
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 7 11:52:30 PDT 2020
Author: mydeveloperday
Date: 2020-05-07T19:52:12+01:00
New Revision: 3125aa99593db9fe17c825fd5984b333bb86437f
URL: https://github.com/llvm/llvm-project/commit/3125aa99593db9fe17c825fd5984b333bb86437f
DIFF: https://github.com/llvm/llvm-project/commit/3125aa99593db9fe17c825fd5984b333bb86437f.diff
LOG: [clang-format] ensure dump_format_style.py works with Python3 correctly
Summary:
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'
```
Reviewed By: krasimir
Subscribers: cfe-commits
Tags: #clang, #clang-format
Differential Revision: https://reviews.llvm.org/D79326
Added:
Modified:
clang/docs/tools/dump_format_style.py
Removed:
################################################################################
diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py
index acb0dfcaf4a7..61167979b3e6 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -225,4 +225,4 @@ class State(object):
contents = substitute(contents, 'FORMAT_STYLE_OPTIONS', options_text)
with open(DOC_FILE, 'wb') as output:
- output.write(contents)
+ output.write(contents.encode())
More information about the cfe-commits
mailing list