Skip to content
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

Add extra test for IO.new with internal_encoding keyword #1075

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

herwinw
Copy link
Member

@herwinw herwinw commented Sep 10, 2023

When providing a single encoding in the mode argument, the external encoding of the IO object is set to that encoding, the internal encoding is left blank. The ArgumentError in this case is a rather specific behaviour.

I'm marking this one as Draft for now, I'm not exactly sure if this is the intended behaviour.

When providing a single encoding in the mode argument, the external
encoding of the IO object is set to that encoding, the internal encoding
is left blank. The ArgumentError in this case is a rather specific
behaviour.
@herwinw
Copy link
Member Author

herwinw commented Sep 10, 2023

Snippet of the observed behaviour (Ruby 3.1)

irb(main):001:0> io = IO.new(1, 'w:ISO-8859-1')
=> #<IO:fd 1>
irb(main):002:0> io.internal_encoding
=> nil
irb(main):003:0> io.external_encoding
=> #<Encoding:ISO-8859-1>
irb(main):004:0> io = IO.new(1, 'w:ISO-8859-1', internal_encoding: 'ISO-8859-1')
(irb):4:in `initialize': encoding specified twice (ArgumentError)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant