Skip to content

Commit

Permalink
[clang-format] ensure dump_format_style.py works with Python3 correctly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mydeveloperday committed May 7, 2020
1 parent 305a4ab commit 3125aa9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/docs/tools/dump_format_style.py
Expand Up @@ -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())

0 comments on commit 3125aa9

Please sign in to comment.