Skip to content

Commit 75a281b

Browse files
committed
Fix IO#write to not modify the argument when the encoding does not match
1 parent 8b677ad commit 75a281b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Bug fixes:
55
* Set `RbConfig::CONFIG['ruby_version']` to the same value as the TruffleRuby version. This fixes reusing C extensions between different versions of TruffleRuby with Bundler (#1715).
66
* Fixed `Symbol#match` returning `MatchData` (#1706).
77
* Allow `Time#strftime` to be called with binary format strings.
8+
* Do not modify the argument passed to `IO#write` when the encoding does not match (#1714).
89

910
Compatibility:
1011

src/main/ruby/truffleruby/core/io.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,7 +2549,7 @@ def write(data)
25492549
external_encoding != data.encoding &&
25502550
external_encoding != Encoding::ASCII_8BIT
25512551
unless data.ascii_only? && external_encoding.ascii_compatible?
2552-
data.encode!(external_encoding)
2552+
data = data.encode(external_encoding)
25532553
end
25542554
end
25552555

0 commit comments

Comments
 (0)