diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | object.c | 12 |
2 files changed, 14 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Wed Nov 7 09:15:58 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * object.c (rb_mod_const_get): avoid inadvertent symbol creation. + Wed Nov 7 07:52:50 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * enum.c (rb_enum_cycle_size): prefix with rb. @@ -1947,13 +1947,21 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) } while (*p) { + VALUE part; + while (*p && *p != ':') p++; if (pbeg == p) { rb_raise(rb_eNameError, "wrong constant name %s", path); } - id = rb_intern3(pbeg, p-pbeg, enc); + id = rb_check_id_cstr(pbeg, p-pbeg, enc); + if (id) { + part = ID2SYM(id); + } + else { + part = rb_str_subseq(name, pbeg-path, p-pbeg); + } if (p[0] == ':') { if (p[1] != ':') { rb_raise(rb_eNameError, "wrong constant name %s", path); @@ -1966,7 +1974,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod) rb_raise(rb_eTypeError, "%s does not refer to class/module", path); } - mod = rb_mod_single_const_get(mod, ID2SYM(id), recur); + mod = rb_mod_single_const_get(mod, part, recur); } return mod; |