Write stubs with utf-8 encoding#16329
Merged
JelleZijlstra merged 2 commits intopython:masterfrom Oct 27, 2023
Merged
Conversation
This is to ensure that you don't get encoding errors if docstrings contains odd characters like emojis.
Member
|
Would you mind adding a test that includes a non-ASCII character in a docstring? |
Contributor
Author
|
I had a short stab at adding a unit test. Simplest test of this as I can tell is to add it to the stubgen.test, but I'm having a hard time running this. Simplest example of showing the problem is with open("test", "w") as f:
f.write("\U0001F60A")Adding encoding="utf-8" to this fixes the problem. This is on Windows. On Linux I would not imagin this being a problem. The workaround for this is setting PYTHONUTF8=1 but I spent some time finding this, and I imagined the patch it would save someone else this time. |
JelleZijlstra
approved these changes
Oct 27, 2023
Contributor
Author
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is to ensure that you don't get encoding errors if docstrings contains odd characters like emojis.