File tree Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Expand file tree Collapse file tree 4 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,12 @@ New features:
9
9
Bug fixes:
10
10
11
11
* Adding missing support for the ` close_others ` option to ` exec ` and ` spawn ` .
12
- * Allow signal ` 0 ` to be used with ` Process.kill ` .
13
12
* FFI::Pointer now does the correct range checks for signed and unsigned values.
14
13
* Allow signal ` 0 ` to be used with ` Process.kill ` (#1474 ).
15
14
* ` IO#dup ` now properly sets the new ` IO ` instance to be close-on-exec.
16
15
* ` IO#reopen ` now properly resets the receiver to be close-on-exec.
16
+ * ` StringIO#set_encoding ` no longer raises an exception if the underlying
17
+ ` String ` is frozen (#1473 ).
17
18
18
19
Changes:
19
20
Original file line number Diff line number Diff line change @@ -120,7 +120,8 @@ def check_writable
120
120
def set_encoding ( external , internal = nil , options = nil )
121
121
encoding = external || Encoding . default_external
122
122
@__data__ . encoding = encoding
123
- @__data__ . string . force_encoding ( encoding )
123
+ @__data__ . string . force_encoding ( encoding ) if @writable
124
+
124
125
self
125
126
end
126
127
Original file line number Diff line number Diff line change 2
2
require_relative '../../spec_helper'
3
3
4
4
describe "StringIO#set_encoding" do
5
- it "sets the encoding of the underlying String" do
6
- io = StringIO . new
5
+ it "sets the encoding of the underlying String if the String is not frozen" do
6
+ str = "" . encode ( Encoding ::US_ASCII )
7
+
8
+ io = StringIO . new ( str )
7
9
io . set_encoding Encoding ::UTF_8
8
10
io . string . encoding . should == Encoding ::UTF_8
9
11
end
12
+
13
+ it "does not set the encoding of the underlying String if the String is frozen" do
14
+ str = "" . encode ( Encoding ::US_ASCII ) . freeze
15
+
16
+ io = StringIO . new ( str )
17
+ io . set_encoding Encoding ::UTF_8
18
+ io . string . encoding . should == Encoding ::US_ASCII
19
+ end
10
20
end
Original file line number Diff line number Diff line change 1
- fails:StringIO#external_encoding does not set the encoding of its buffer string if the string is frozen
2
1
fails:StringIO#external_encoding changes to match string if string's encoding is changed
You can’t perform that action at this time.
0 commit comments