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

Fix a crash when a pylint must display unicode raising a UnicodeEncodeError #9732

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Pierre-Sassoulas
Copy link
Member

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Work in progress for #8736, this is probably not the right fix, but it's a fix. Hoping for a surrogates/unicode expert to chime in with the right approach πŸ˜„ !

@Pierre-Sassoulas Pierre-Sassoulas added Work in progress Crash πŸ’₯ A bug that makes pylint crash labels Jun 14, 2024
@Pierre-Sassoulas
Copy link
Member Author

We should probably aim to keep the \ud800\udc00 format instead of transforming to actual utf32 characters.

@DanielNoord
Copy link
Collaborator

https://stackoverflow.com/questions/27366479/python-3-os-walk-file-paths-unicodeencodeerror-utf-8-codec-cant-encode-s

encode('utf8','replace') seems to work? Although I really don't like that we need to add special logic for a really uncommon case..

@@ -0,0 +1 @@
comparison-of-constants:3:7:3:37::"Comparison between constants: '𐀀 == ' has a constant value":HIGH
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
comparison-of-constants:3:7:3:37::"Comparison between constants: '𐀀 == ' has a constant value":HIGH
comparison-of-constants:3:7:3:37::"Comparison between constants: '"\U00010000" == "\ud800\udc00"' has a constant value":HIGH

Imo we should aim for this, but I have an intuition that the ast module internal might be involved.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but I don't think we can. self.out is utf-8 encoded so we always need to encode/escape to utf-8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash πŸ’₯ A bug that makes pylint crash Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants