summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-24 13:46:04 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-24 13:46:04 +0000
commitcafc5a30805e647d7920343cc7056d95263f58b8 (patch)
tree92aa673c75956611d76dc2b2dcfa6cbeb7dd70f0
parent57b26f83051d13442ffa6269230ea9d5803b6d1b (diff)
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
-rw-r--r--ChangeLog5
-rw-r--r--encoding.c4
-rw-r--r--test/ruby/test_encoding.rb8
-rw-r--r--version.h6
4 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 212905a307..86d2a3d5d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Oct 24 22:36:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * encoding.c (load_encoding): should preserve outer errinfo, so that
+ expected exception may not be lost. [ruby-core:57949] [Bug #9038]
+
Fri Oct 18 02:10:00 2013 Shugo Maeda <shugo@ruby-lang.org>
* vm_insnhelper.c (vm_call_method): set ci->me to 0 when the
diff --git a/encoding.c b/encoding.c
index c94dc90a7e..26a87913dc 100644
--- a/encoding.c
+++ b/encoding.c
@@ -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;
diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb
index ef2dc39c4d..82f1a306f0 100644
--- a/test/ruby/test_encoding.rb
+++ b/test/ruby/test_encoding.rb
@@ -113,4 +113,12 @@ class TestEncoding < Test::Unit::TestCase
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;")
+ e = assert_raise(SyntaxError) { eval("/regexp/sQ") }
+ assert_match(/unknown regexp option - Q/, e.message, #{bug9038.dump})
+ end;
+ end
end
diff --git a/version.h b/version.h
index 1282fad84c..80eaec0284 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-10-18"
-#define RUBY_PATCHLEVEL 337
+#define RUBY_RELEASE_DATE "2013-10-24"
+#define RUBY_PATCHLEVEL 338
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 18
+#define RUBY_RELEASE_DAY 24
#include "ruby/version.h"