* encoding.c (rb_find_encoding): new function find encoding from

arbitrary object as a pointer to rb_encoding, and return NULL if
  not found.
* io.c (io_encoding_set): just warn unsupported encodings, but not
  exception.  [ruby-core:40726] [Bug #5567]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-03-12 10:23:17 +00:00
parent c60602acbc
commit 33ceea5cdb
5 changed files with 59 additions and 7 deletions

View file

@ -1060,6 +1060,17 @@ EOT
}
end
def test_set_encoding_unsupported
bug5567 = '[ruby-core:40726]'
IO.pipe do |r, w|
assert_nothing_raised(bug5567) do
assert_warn(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx")}
assert_warn(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx", "us-ascii")}
assert_warn(/Unsupported/, bug5567) {r.set_encoding("us-ascii", "fffffffffffxx")}
end
end
end
def test_textmode_twice
assert_raise(ArgumentError) {
open(__FILE__, "rt", textmode: true) {|f|