ruby-changes:33102
From: nobu <ko1@a...>
Date: Wed, 26 Feb 2014 14:10:51 +0900 (JST)
Subject: [ruby-changes:33102] nobu:r45181 (trunk): eval.c: preserve encoding
nobu 2014-02-26 14:10:46 +0900 (Wed, 26 Feb 2014) New Revision: 45181 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45181 Log: eval.c: preserve encoding * eval.c (setup_exception): preserve exception class name encoding in debug mode messages. Modified files: trunk/ChangeLog trunk/eval.c trunk/test/ruby/test_exception.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 45180) +++ ChangeLog (revision 45181) @@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Wed Feb 26 13:26:21 2014 Nobuyoshi Nakada <nobu@r...> +Wed Feb 26 14:10:44 2014 Nobuyoshi Nakada <nobu@r...> + + * 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] Index: eval.c =================================================================== --- eval.c (revision 45180) +++ eval.c (revision 45181) @@ -518,16 +518,16 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L518 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(); Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 45180) +++ test/ruby/test_exception.rb (revision 45181) @@ -100,6 +100,23 @@ class TestException < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L100 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/