summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-08 00:44:05 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-08 00:44:05 +0000
commit79634569e483d82874c9eaadf0d3a61c1b529fa8 (patch)
treeaea23d11a3cde8a68741cb49dd69b7aff6d590af
parentb7f40d86af3e98c4481caf1014ba5423901d4580 (diff)
merge revision(s) 34028,34030:
* 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. ignore exception under rb_protect(). [ruby-core:41612] [Bug #5755] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--error.c5
-rw-r--r--test/ruby/test_exception.rb17
-rw-r--r--version.h2
4 files changed, 30 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d05a23ab7..ef0f877333 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Feb 8 09:43:48 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
+
+ * error.c (name_err_mesg_to_str): clear rb_thread_t::errinfo when
+ ignore exception under rb_protect(). [ruby-core:41612] [Bug #5755]
+
+ * test/ruby/test_exception.rb (test_exception_in_name_error_to_str):
+ add a corresponding test.
+
Wed Feb 8 09:36:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (require_enc): reject only loading from untrusted
diff --git a/error.c b/error.c
index ce959fc221..e5ca4e7c90 100644
--- a/error.c
+++ b/error.c
@@ -955,6 +955,7 @@ name_err_mesg_to_str(VALUE obj)
else {
const char *desc = 0;
VALUE d = 0, args[NAME_ERR_MESG_COUNT];
+ int state = 0;
obj = ptr[1];
switch (TYPE(obj)) {
@@ -968,7 +969,9 @@ name_err_mesg_to_str(VALUE obj)
desc = "false";
break;
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) {
d = rb_any_to_s(obj);
}
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index a26ade075b..b410b708b5 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1,4 +1,5 @@
require 'test/unit'
+require 'tempfile'
require_relative 'envutil'
class TestException < Test::Unit::TestCase
@@ -316,4 +317,20 @@ end.join
def test_errno
assert_equal(Encoding.find("locale"), Errno::EINVAL.new.message.encoding)
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
diff --git a/version.h b/version.h
index 68e938f5ef..b29f38b218 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 51
+#define RUBY_PATCHLEVEL 52
#define RUBY_RELEASE_DATE "2012-02-08"
#define RUBY_RELEASE_YEAR 2012