diff options
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | test/ruby/test_io.rb | 7 |
2 files changed, 8 insertions, 3 deletions
@@ -7618,9 +7618,9 @@ static VALUE rb_io_s_new(int argc, VALUE *argv, VALUE klass) { if (rb_block_given_p()) { - const char *cname = rb_class2name(klass); + VALUE cname = rb_obj_as_string(klass); - rb_warn("%s::new() does not take block; use %s::open() instead", + rb_warn("%"PRIsVALUE"::new() does not take block; use %"PRIsVALUE"::open() instead", cname, cname); } return rb_class_new_instance(argc, argv, klass); diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 126100e096..08f39c3a4a 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2282,7 +2282,12 @@ End end def test_new_with_block - assert_in_out_err([], "r, w = IO.pipe; IO.new(r) {}", [], /^.+$/) + assert_in_out_err([], "r, w = IO.pipe; IO.new(r.fileno) {}", [], /^.+$/) + n = "IO\u{5165 51fa 529b}" + c = eval("class #{n} < IO; self; end") + IO.pipe do |r, w| + assert_warning(/#{n}/) {c.new(r.fileno) {}} + end end def test_readline2 |