merge revision(s) 43376: [Backport #9038]

* encoding.c (load_encoding): should preserve outer errinfo, so that
	  expected exception may not be lost.  [ruby-core:57949] [Bug #9038]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagachika 2013-10-24 13:46:04 +00:00
parent 57b26f8305
commit cafc5a3080
4 changed files with 19 additions and 4 deletions

View file

@ -582,6 +582,7 @@ load_encoding(const char *name)
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;
@ -595,10 +596,11 @@ load_encoding(const char *name)
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;