summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-07 00:16:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-07 00:16:03 +0000
commitbd9b31e557ca557aa2ae8b5908c71e1250e450c8 (patch)
tree9f32c2bd49c17fe8ead6abb162b0da599ff9cc3f /object.c
parentdb54dc7215bc6838feaea452a13a8954cdad8a7b (diff)
object.c: inadvertent symbol
* object.c (rb_mod_const_get): avoid inadvertent symbol creation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/object.c b/object.c
index 89706dd9e7..4d4daaf006 100644
--- a/object.c
+++ b/object.c
@@ -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;