summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-26 05:10:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-26 05:10:46 +0000
commita8cb9b02a0ad6c9bb656ce5154c5483de36f5b12 (patch)
tree555909c564464258db2d0b1424c26e177d084525
parent651b394a12fba26b9c64676978f9b2b3205c0b14 (diff)
eval.c: preserve encoding
* eval.c (setup_exception): preserve exception class name encoding in debug mode messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--eval.c12
-rw-r--r--test/ruby/test_exception.rb17
3 files changed, 27 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 8418ce8..8001871 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-Wed Feb 26 13:26:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Wed Feb 26 14:10:44 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (setup_exception): preserve exception class name encoding
+ in debug mode messages.
* eval.c (setup_exception): preserve errinfo across calling #to_s
method on the exception. [ruby-core:61091] [Bug #9568]
diff --git a/eval.c b/eval.c
index a70a7a9..761b770 100644
--- a/eval.c
+++ b/eval.c
@@ -518,16 +518,16 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
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);
+ warn_printf("Exception `%"PRIsVALUE"' at %s:%d - %"PRIsVALUE"\n",
+ rb_obj_class(mesg), file, line, e);
}
else if (file) {
- warn_printf("Exception `%s' at %s - %"PRIsVALUE"\n",
- rb_obj_classname(th->errinfo), file, e);
+ warn_printf("Exception `%"PRIsVALUE"' at %s - %"PRIsVALUE"\n",
+ rb_obj_class(mesg), file, e);
}
else {
- warn_printf("Exception `%s' - %"PRIsVALUE"\n",
- rb_obj_classname(th->errinfo), e);
+ warn_printf("Exception `%"PRIsVALUE"' - %"PRIsVALUE"\n",
+ rb_obj_class(mesg), e);
}
}
POP_TAG();
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index ffcee80..aabe146 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -100,6 +100,23 @@ class TestException < Test::Unit::TestCase
assert_include(err, bug9568.to_s)
end
+ def test_errinfo_encoding_in_debug
+ exc = Module.new {break class_eval("class C\u{30a8 30e9 30fc} < RuntimeError; self; end".encode(Encoding::EUC_JP))}
+ exc.inspect
+
+ err = EnvUtil.verbose_warning do
+ assert_raise(exc) do
+ $DEBUG, debug = true, $DEBUG
+ begin
+ raise exc
+ ensure
+ $DEBUG = debug
+ end
+ end
+ end
+ assert_include(err, exc.to_s)
+ end
+
def test_break_ensure
bad = true
while true