Repository navigation
Keep the encoding of constant names in constant warnings - #10089
Open
sampokuokkanen wants to merge 2 commits into
Open
sampokuokkanen wants to merge 2 commits into
sampokuokkanen wants to merge 2 commits into
Conversation
The "already initialized constant" and "constant ... is deprecated" warnings joined the constant's id string (raw bytes) into a Java String, so X定数 printed as X宿°. Build the message as a RubyString and quote the name like CRuby's QUOTE_ID, with a new port of rb_id_quote_unprintable. If the module and constant names have incompatible encodings, escape the constant name so the warning cannot raise Encoding::CompatibilityError. Name the module by its class path, not to_s, as CRuby does. Narrow the TestConst#test_redefinition exclude to the missing "previous definition" line.
headius
requested changes
Nov 17, 2026
headius
left a comment
Member
There was a problem hiding this comment.
I believe this change could be made smaller by using the str methods in RubyStringBuilder, which have various forms to properly handle encoding an error string. There's several examples in the codebase.
Contributor
Author
|
Switched to |
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.
The "already initialized constant" and "constant ... is deprecated" warnings joined the constant's id string (raw bytes) into a Java String, so X定数 printed as X宿°.
Build the message as a RubyString and quote the name like CRuby's
QUOTE_ID, with a new port of rb_id_quote_unprintable. If the module and constant names have incompatible encodings, escape the constant name so the warning cannot raiseEncoding::CompatibilityError. Name the module by its class path, not to_s, as CRuby does.Narrow the
TestConst#test_redefinitionexclude to the missing "previous definition" line.