summaryrefslogtreecommitdiffstats
path: root/vm_method.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-19 15:07:45 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-19 15:07:45 +0000
commit7775cf045ac2f308d4796c4cd58629d9100ada01 (patch)
tree39f7750a95a282f2edb4a777196296fa62cb4150 /vm_method.c
parent495a98e0bfd395d1c78f37b28cd781651e35ebe5 (diff)
downloadruby-7775cf045ac2f308d4796c4cd58629d9100ada01.tar.gz
ruby-7775cf045ac2f308d4796c4cd58629d9100ada01.tar.xz
ruby-7775cf045ac2f308d4796c4cd58629d9100ada01.zip
* vm_method.c (rb_attr): should preserve encoding info.
[ruby-dev:38498] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index 25d2e6d0c..f32ba388a 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -446,6 +446,7 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex)
{
const char *name;
ID attriv;
+ VALUE aname;
int noex;
if (!ex) {
@@ -473,7 +474,9 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex)
if (!name) {
rb_raise(rb_eArgError, "argument needs to be symbol or string");
}
- attriv = rb_intern_str(rb_sprintf("@%s", name));
+ aname = rb_sprintf("@%s", name);
+ rb_enc_copy(aname, rb_id2str(id));
+ attriv = rb_intern_str(aname);
if (read) {
rb_add_method(klass, id, NEW_IVAR(attriv), noex);
}