1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] Ignore any encoding errors while symbol completion

https://github.com/ruby/irb/commit/daa65cded1
This commit is contained in:
Nobuyoshi Nakada 2021-09-23 16:28:28 +09:00 committed by git
parent e6118c8108
commit ede95f541b
2 changed files with 5 additions and 1 deletions

View file

@ -192,7 +192,7 @@ module IRB
sym = $1
candidates = Symbol.all_symbols.collect do |s|
":" + s.id2name.encode(Encoding.default_external)
rescue Encoding::UndefinedConversionError
rescue EncodingError
# ignore
rescue Encoding::InvalidByteSequenceError => e
raise "Invalid byte sequence #{s.id2name.bytes.inspect} #{e.inspect}"

View file

@ -27,6 +27,10 @@ module TestIRB
end
def test_complete_symbol
%w"UTF-16LE UTF-7".each do |enc|
"K".force_encoding(enc).to_sym
rescue
end
_ = :aiueo
assert_include(IRB::InputCompletor.retrieve_completion_data(":a", bind: binding), ":aiueo")
assert_empty(IRB::InputCompletor.retrieve_completion_data(":irb_unknown_symbol_abcdefg", bind: binding))