ruby-changes:31297
From: nobu <ko1@a...>
Date: Mon, 21 Oct 2013 23:57:59 +0900 (JST)
Subject: [ruby-changes:31297] nobu:r43376 (trunk): encoding.c: preserve outer errinfo
nobu 2013-10-21 23:57:55 +0900 (Mon, 21 Oct 2013) New Revision: 43376 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43376 Log: encoding.c: preserve outer errinfo * encoding.c (load_encoding): should preserve outer errinfo, so that expected exception may not be lost. [ruby-core:57949] [Bug #9038] Modified files: trunk/ChangeLog trunk/encoding.c trunk/test/ruby/test_encoding.rb Index: encoding.c =================================================================== --- encoding.c (revision 43375) +++ encoding.c (revision 43376) @@ -623,6 +623,7 @@ load_encoding(const char *name) https://github.com/ruby/ruby/blob/trunk/encoding.c#L623 VALUE enclib = rb_sprintf("enc/%s.so", name); VALUE verbose = ruby_verbose; VALUE debug = ruby_debug; + VALUE errinfo; VALUE loaded; char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib) - 3; int idx; @@ -636,10 +637,11 @@ load_encoding(const char *name) https://github.com/ruby/ruby/blob/trunk/encoding.c#L637 OBJ_FREEZE(enclib); ruby_verbose = Qfalse; ruby_debug = Qfalse; + errinfo = rb_errinfo(); loaded = rb_protect(require_enc, enclib, 0); ruby_verbose = verbose; ruby_debug = debug; - rb_set_errinfo(Qnil); + rb_set_errinfo(errinfo); if (NIL_P(loaded)) return -1; if ((idx = rb_enc_registered(name)) < 0) return -1; if (enc_autoload_p(enc_table.list[idx].enc)) return -1; Index: ChangeLog =================================================================== --- ChangeLog (revision 43375) +++ ChangeLog (revision 43376) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Oct 21 23:57:53 2013 Nobuyoshi Nakada <nobu@r...> + + * encoding.c (load_encoding): should preserve outer errinfo, so that + expected exception may not be lost. [ruby-core:57949] [Bug #9038] + Sun Oct 20 15:41:22 2013 Nobuyoshi Nakada <nobu@r...> * io.c (rb_io_reopen): create a new, temporary FD via rb_sysopen and Index: test/ruby/test_encoding.rb =================================================================== --- test/ruby/test_encoding.rb (revision 43375) +++ test/ruby/test_encoding.rb (revision 43376) @@ -108,4 +108,13 @@ class TestEncoding < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_encoding.rb#L108 asc = "b".force_encoding(Encoding::US_ASCII) assert_equal(Encoding::ASCII_8BIT, Encoding.compatible?(bin, asc)) end + + def test_errinfo_after_autoload + bug9038 = '[ruby-core:57949] [Bug #9038]' + assert_separately(%w[--disable=gems], <<-"end;") + assert_raise_with_message(SyntaxError, /unknown regexp option - Q/, #{bug9038.dump}) { + eval("/regexp/sQ") + } + end; + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/