Fix Encoding::ConverterNotFoundError#238
Merged
aycabta merged 1 commit intoruby:masterfrom May 11, 2021
Merged
Conversation
Follow ruby#237. This PR fixes the following `Encoding::ConverterNotFoundError`. ```console % bin/spring stop && bin/rails c Spring stopped. Running via Spring preloader in process 58395 Loading development environment (Rails 6.0.3.7) irb(main):001:0> "こんにちは".do_something Traceback (most recent call last): (snip) 12: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:547:in `eval_input' 11: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:232:in `each_top_level_statement' 10: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:232:in `catch' 9: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:233:in `block in each_top_level_statement' 8: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:233:in `loop' 7: from /Users/koic/src/github.com/ruby/irb/lib/irb/ruby-lex.rb:251:in `block (2 levels) in each_top_level_statement' 6: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:548:in `block in eval_input' 5: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:758:in `signal_status' 4: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:586:in `block (2 levels) in eval_input' 3: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:650:in `handle_exception' 2: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:601:in `encode_with_invalid_byte_sequence' 1: from /Users/koic/src/github.com/ruby/irb/lib/irb.rb:601:in `new' /Users/koic/src/github.com/ruby/irb/lib/irb.rb:601:in `initialize': code converter not found (UTF-8 to UTF-8) (Encoding::ConverterNotFoundError) ``` First, this patch skips `Encoding::Converter.new` for the same encoding. https://github.com/ruby/irb/blob/170531df19bce289444afe97360480efed5f27f0/lib/irb.rb#L601 Next, this is a talk about the condition for skipping. `IRB.conf[:LC_MESSAGES].encoding` becomes `"UTF-8"` string when `Reline.encoding_system_needs.name` is set in the below. https://github.com/ruby/irb/blob/170531df19bce289444afe97360480efed5f27f0/lib/irb/input-method.rb#L269 OTOH, `message.encoding` is `Encoding::UTF_8`, so these are compared as a string by this patch.
Member
|
Great! |
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.
Follow #237.
This PR fixes the following
Encoding::ConverterNotFoundError.First, this patch skips
Encoding::Converter.newfor the same encoding.irb/lib/irb.rb
Line 601 in 170531d
Next, this is a talk about the condition for skipping.
IRB.conf[:LC_MESSAGES].encodingbecomes"UTF-8"string whenReline.encoding_system_needs.nameis set in the below.irb/lib/irb/input-method.rb
Line 269 in 170531d
OTOH,
message.encodingisEncoding::UTF_8, so these are compared as a string by this patch.