error.c: infinite recursion at Warning#warn
* error.c (rb_warn_m): write the message to rb_stderr directly, to get rid of infinite recursion when called on Warning module itself, by super in redefined Warning#warn. [ruby-dev:50293] [Bug #14006] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a16d03365
commit
8a2a882e53
6
error.c
6
error.c
@ -329,8 +329,14 @@ rb_warn_m(int argc, VALUE *argv, VALUE exc)
|
|||||||
rb_io_puts(argc, argv, str);
|
rb_io_puts(argc, argv, str);
|
||||||
RBASIC_SET_CLASS(str, rb_cString);
|
RBASIC_SET_CLASS(str, rb_cString);
|
||||||
}
|
}
|
||||||
|
if (exc == rb_mWarning) {
|
||||||
|
rb_must_asciicompat(str);
|
||||||
|
rb_write_error_str(str);
|
||||||
|
}
|
||||||
|
else {
|
||||||
rb_write_warning_str(str);
|
rb_write_warning_str(str);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,6 +1034,20 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||||||
assert_match(/^\tfrom #{Regexp.escape(path)}:1:/, warning.first)
|
assert_match(/^\tfrom #{Regexp.escape(path)}:1:/, warning.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_warning_warn_super
|
||||||
|
assert_in_out_err(%[-W0], "#{<<~"{#"}\n#{<<~'};'}", [], /instance variable @a not initialized/)
|
||||||
|
{#
|
||||||
|
module Warning
|
||||||
|
def warn(message)
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
$VERBOSE = true
|
||||||
|
@a
|
||||||
|
};
|
||||||
|
end
|
||||||
|
|
||||||
def test_undefined_backtrace
|
def test_undefined_backtrace
|
||||||
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
|
assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
|
||||||
begin;
|
begin;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user