Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-format] Explicitly open DOC_FILE with utf-8 in dump_format_style.py #79805

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

rmarker
Copy link
Contributor

@rmarker rmarker commented Jan 29, 2024

The dump_format_style.py script generates the clang-format style options documentation.
There was an issue where the script could include spurious characters in the output when run in windows. It appears that it wasn't defaulting to the correct encoding when reading the input.
This has been addressed by explicitly setting the encoding when opening the file.

…le.py.

The dump_format_style script generates the clang-format style options documentation.
There was an issue where the script could include spurious characters in the output when run in windows.
It appears that it wasn't defaulting to the correct encoding when reading the input.
This has been addressed by explicitly setting the encoding when opening the file.
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 29, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 29, 2024

@llvm/pr-subscribers-clang-format

@llvm/pr-subscribers-clang

Author: None (rmarker)

Changes

The dump_format_style.py script generates the clang-format style options documentation.
There was an issue where the script could include spurious characters in the output when run in windows. It appears that it wasn't defaulting to the correct encoding when reading the input.
This has been addressed by explicitly setting the encoding when opening the file.


Full diff: https://github.com/llvm/llvm-project/pull/79805.diff

1 Files Affected:

  • (modified) clang/docs/tools/dump_format_style.py (+1-1)
diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py
index 75d4a044ef19f68..e41891f07de2e32 100755
--- a/clang/docs/tools/dump_format_style.py
+++ b/clang/docs/tools/dump_format_style.py
@@ -474,7 +474,7 @@ class State:
 opts = sorted(opts, key=lambda x: x.name)
 options_text = "\n\n".join(map(str, opts))
 
-with open(DOC_FILE) as f:
+with open(DOC_FILE, encoding="utf-8") as f:
     contents = f.read()
 
 contents = substitute(contents, "FORMAT_STYLE_OPTIONS", options_text)

@rmarker
Copy link
Contributor Author

rmarker commented Jan 29, 2024

@HazardyKnusperkeks, @owenca, extracted this change from #78011.

Copy link
Contributor

@HazardyKnusperkeks HazardyKnusperkeks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@owenca owenca added clang-format and removed clang Clang issues not falling into any other category labels Jan 31, 2024
@owenca owenca merged commit c806d8c into llvm:main Jan 31, 2024
7 checks passed
@rmarker rmarker deleted the ExplicitEncoding branch January 31, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants