Bug #11945 ยป 0001-stringio-binmode-sets-encoding-to-ASCII-8BIT.patch
| ext/stringio/stringio.c | ||
|---|---|---|
|
return lineno;
|
||
|
}
|
||
|
#define strio_binmode strio_self
|
||
|
static VALUE
|
||
|
strio_binmode(VALUE self)
|
||
|
{
|
||
|
struct StringIO *ptr = StringIO(self);
|
||
|
rb_encoding *enc = rb_ascii8bit_encoding();
|
||
|
ptr->enc = enc;
|
||
|
if (WRITABLE(self)) {
|
||
|
rb_enc_associate(ptr->string, enc);
|
||
|
}
|
||
|
return self;
|
||
|
}
|
||
|
#define strio_fcntl strio_unimpl
|
||
| test/stringio/test_stringio.rb | ||
|---|---|---|
|
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line(0){} }
|
||
|
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line("a",0){} }
|
||
|
end
|
||
|
def test_binmode
|
||
|
s = StringIO.new
|
||
|
s.set_encoding('utf-8')
|
||
|
assert_same s, s.binmode
|
||
|
assert_equal Encoding::ASCII_8BIT, s.external_encoding
|
||
|
end
|
||
|
end
|
||
|
-
|
||