diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 11:42:24 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-06 11:42:24 +0000 |
commit | ac7f5157ac9d35b40da74ad932e9997f3f3e38a4 (patch) | |
tree | 5475ac890dc8c95f3a1033f84776bfd3ae889001 /object.c | |
parent | e5e5d0c55efb5f51c6825c58a95f9ad77408b1d1 (diff) |
* object.c (rb_mod_const_get): Fix constant missing exception class
and message to maintain backwards compatibility. Constant search
should start at Object when constant starts with '::'
* test/ruby/test_module.rb: test for fixes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -1935,12 +1935,28 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) } pbeg = p = path; + + if (!*p) { + rb_raise(rb_eNameError, "wrong constant name %s", path); + } + + if (p[0] == ':' && p[1] == ':') { + mod = rb_cObject; + p += 2; + pbeg = p; + } + while (*p) { while (*p && *p != ':') p++; + + if (pbeg == p) { + rb_raise(rb_eNameError, "wrong constant name %s", path); + } + id = rb_intern3(pbeg, p-pbeg, enc); if (p[0] == ':') { if (p[1] != ':') { - rb_raise(rb_eArgError, "undefined class/module %.*s", (int)(p-path), path); + rb_raise(rb_eNameError, "wrong constant name %s", path); } p += 2; pbeg = p; |