diff options
| author | tomoya ishida <tomoyapenguin@gmail.com> | 2024-11-28 03:51:01 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-11-27 18:51:04 +0000 |
| commit | 34a43d59721bfc492d133875e43664039bf8900e (patch) | |
| tree | b7c99330cd9ff2833e7d9e1ca849e0e53f6d83d1 | |
| parent | 33c6bbca222eacfd0635105666edf892091b8180 (diff) | |
[ruby/reline] Fix io_gate.encoding raises IOError in ruby <= 3.0
(https://github.com/ruby/reline/pull/785)
https://github.com/ruby/reline/commit/85e20f0031
| -rw-r--r-- | lib/reline/io/ansi.rb | 3 | ||||
| -rw-r--r-- | lib/reline/io/dumb.rb | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/reline/io/ansi.rb b/lib/reline/io/ansi.rb index 4fd0023259..c51e97b722 100644 --- a/lib/reline/io/ansi.rb +++ b/lib/reline/io/ansi.rb @@ -38,6 +38,9 @@ class Reline::ANSI < Reline::IO def encoding @input.external_encoding || Encoding.default_external + rescue IOError + # STDIN.external_encoding raises IOError in Ruby <= 3.0 when STDIN is closed + Encoding.default_external end def set_default_key_bindings(config) diff --git a/lib/reline/io/dumb.rb b/lib/reline/io/dumb.rb index 34bba98ba1..e58ba0f6d8 100644 --- a/lib/reline/io/dumb.rb +++ b/lib/reline/io/dumb.rb @@ -21,8 +21,11 @@ class Reline::Dumb < Reline::IO elsif RUBY_PLATFORM =~ /mswin|mingw/ Encoding::UTF_8 else - @input.external_encoding || Encoding::default_external + @input.external_encoding || Encoding.default_external end + rescue IOError + # STDIN.external_encoding raises IOError in Ruby <= 3.0 when STDIN is closed + Encoding.default_external end def set_default_key_bindings(_) |
