mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* error.c (name_err_mesg_to_str): clear rb_thread_t::errinfo when
ignore exception under rb_protect(). * test/ruby/test_exception.rb (test_exception_in_name_error_to_str): add a corresponding test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ab6c8910f4
commit
d61d9d5e8e
3 changed files with 29 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Tue Dec 13 23:43:48 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
|
||||||
|
|
||||||
|
* error.c (name_err_mesg_to_str): clear rb_thread_t::errinfo when
|
||||||
|
ignore exception under rb_protect().
|
||||||
|
|
||||||
|
* test/ruby/test_exception.rb (test_exception_in_name_error_to_str):
|
||||||
|
add a corresponding test.
|
||||||
|
|
||||||
Tue Dec 13 16:13:29 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Dec 13 16:13:29 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* load.c (load_unlock): all threads requiring one file should
|
* load.c (load_unlock): all threads requiring one file should
|
||||||
|
|
5
error.c
5
error.c
|
@ -1012,6 +1012,7 @@ name_err_mesg_to_str(VALUE obj)
|
||||||
else {
|
else {
|
||||||
const char *desc = 0;
|
const char *desc = 0;
|
||||||
VALUE d = 0, args[NAME_ERR_MESG_COUNT];
|
VALUE d = 0, args[NAME_ERR_MESG_COUNT];
|
||||||
|
int state = 0;
|
||||||
|
|
||||||
obj = ptr[1];
|
obj = ptr[1];
|
||||||
switch (TYPE(obj)) {
|
switch (TYPE(obj)) {
|
||||||
|
@ -1025,7 +1026,9 @@ name_err_mesg_to_str(VALUE obj)
|
||||||
desc = "false";
|
desc = "false";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
d = rb_protect(rb_inspect, obj, 0);
|
d = rb_protect(rb_inspect, obj, &state);
|
||||||
|
if (state)
|
||||||
|
rb_set_errinfo(Qnil);
|
||||||
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
|
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
|
||||||
d = rb_any_to_s(obj);
|
d = rb_any_to_s(obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
|
require 'tempfile'
|
||||||
require_relative 'envutil'
|
require_relative 'envutil'
|
||||||
|
|
||||||
class TestException < Test::Unit::TestCase
|
class TestException < Test::Unit::TestCase
|
||||||
|
@ -363,4 +364,20 @@ end.join
|
||||||
assert_equal(false, efs.success?, bug5728)
|
assert_equal(false, efs.success?, bug5728)
|
||||||
assert_equal("msg", efs.message, bug5728)
|
assert_equal("msg", efs.message, bug5728)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_exception_in_name_error_to_str
|
||||||
|
bug5575 = '[ruby-core:41612]'
|
||||||
|
t = Tempfile.new(["test_exception_in_name_error_to_str", ".rb"])
|
||||||
|
t.puts <<-EOC
|
||||||
|
begin
|
||||||
|
BasicObject.new.inspect
|
||||||
|
rescue
|
||||||
|
$!.inspect
|
||||||
|
end
|
||||||
|
EOC
|
||||||
|
t.close
|
||||||
|
assert_nothing_raised(NameError, bug5575) do
|
||||||
|
load(t.path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue