mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
eval.c: preserve errinfo
* eval.c (setup_exception): preserve errinfo across calling #to_s method on the exception. [ruby-core:61091] [Bug #9568] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9a4185de25
commit
651b394a12
3 changed files with 30 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Feb 26 13:26:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (setup_exception): preserve errinfo across calling #to_s
|
||||
method on the exception. [ruby-core:61091] [Bug #9568]
|
||||
|
||||
Wed Feb 26 01:29:27 2014 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* string.c (sym_find): Add Symbol.find(str), which returns whether given
|
||||
|
|
3
eval.c
3
eval.c
|
@ -511,9 +511,12 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
|
|||
!rb_obj_is_kind_of(e, rb_eSystemExit)) {
|
||||
int status;
|
||||
|
||||
mesg = e;
|
||||
PUSH_TAG();
|
||||
if ((status = EXEC_TAG()) == 0) {
|
||||
th->errinfo = Qnil;
|
||||
e = rb_obj_as_string(e);
|
||||
th->errinfo = mesg;
|
||||
if (file && line) {
|
||||
warn_printf("Exception `%s' at %s:%d - %"PRIsVALUE"\n",
|
||||
rb_obj_classname(th->errinfo), file, line, e);
|
||||
|
|
|
@ -78,6 +78,28 @@ class TestException < Test::Unit::TestCase
|
|||
assert(!bad)
|
||||
end
|
||||
|
||||
def test_errinfo_in_debug
|
||||
bug9568 = EnvUtil.labeled_class("[ruby-core:61091] [Bug #9568]", RuntimeError) do
|
||||
def to_s
|
||||
require '\0'
|
||||
rescue LoadError
|
||||
self.class.to_s
|
||||
end
|
||||
end
|
||||
|
||||
err = EnvUtil.verbose_warning do
|
||||
assert_raise(bug9568) do
|
||||
$DEBUG, debug = true, $DEBUG
|
||||
begin
|
||||
raise bug9568
|
||||
ensure
|
||||
$DEBUG = debug
|
||||
end
|
||||
end
|
||||
end
|
||||
assert_include(err, bug9568.to_s)
|
||||
end
|
||||
|
||||
def test_break_ensure
|
||||
bad = true
|
||||
while true
|
||||
|
|
Loading…
Reference in a new issue