-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Behaviour of IO#set_encoding
has been changed as of Ruby 3.3
#4058
Comments
Recently, it can cause a timeout. |
IO#set_encoding
has been changed as of Ruby 3.3
After reading following articles, I've got the reason why these tests are failed on Ruby 3.3:
On the other hand, I'm now doubting the specification of So I'm not sure how to resolve this issue for now. |
Thanks!
I agree. |
After further investigation, I found that probably it won't work as expected even on Ruby 3.2 or former. test-set-conding.rb: #!/usr/bin/env ruby
STDIN.set_encoding('ascii-8bit', 'utf-8', invalid: :replace, undef: :replace)
str = STDIN.read
p str.encoding
p str
p str.force_encoding("ascii-8bit") Results with the input string Ruby 3.2: $ ruby -e 'STDOUT.write("foo\xFFbar")' | ruby test-set-conding.rb
#<Encoding:UTF-8>
"foo�bar"
"foo\xEF\xBF\xBDbar"
"foo�bar" Ruby 3.3 $ ruby -e 'STDOUT.write("foo\xFFbar")' | ruby test-set-conding.rb
#<Encoding:ASCII-8BIT>
"foo\xFFbar"
"foo\xFFbar"
"foo\xFFbar" Looking at this result alone, it appears to be working as expected on Ruby 3.2. But when I test it with the input string Ruby 3.2 $ ruby -e 'STDOUT.write("あ\xFFい")' | ruby test-set-conding.rb
#<Encoding:UTF-8>
"�������"
"\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD\xEF\xBF\xBD"
"�������" Ruby 3.3 $ ruby -e 'STDOUT.write("あ\xFFい")' | ruby test-set-conding.rb
#<Encoding:ASCII-8BIT>
"\xE3\x81\x82\xFF\xE3\x81\x84"
"\xE3\x81\x82\xFF\xE3\x81\x84"
"あ\xFFい" Probably the current Fluentd's test expects |
related issue: #4460 |
Now I think Ruby 3.3's change seems better than before.
This result on Ruby 3.2 isn't questionable, because |
I see! |
- internal_encoding
+ external_encoding |
Describe the bug
2 tests of child_process helper always fail in Ruby 3.3.0-dev after https://redmine.ruby-lang.org/issues/18899 is landed.
To Reproduce
Expected behavior
These tests shouldn't fail.
Your Environment
Your Configuration
Your Error Log
Additional context
No response
The text was updated successfully, but these errors were encountered: