diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-09 09:03:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-09 09:03:07 +0000 |
commit | e70f74c3d287e2f8cb3aed80ffaaad0902a3af2c (patch) | |
tree | c93ae2a9643b2b3c5ca96c748b425414e6a334b9 /vm_method.c | |
parent | ef46e8d2645cb8987c558102430cc5a642f6232b (diff) | |
download | ruby-e70f74c3d287e2f8cb3aed80ffaaad0902a3af2c.tar.gz |
vm_method.c: preserve encoding
* vm_method.c (rb_attr): preserve encoding of the attribute ID in
error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/vm_method.c b/vm_method.c index da1a94c70a..584982d51d 100644 --- a/vm_method.c +++ b/vm_method.c @@ -812,7 +812,6 @@ rb_method_boundp(VALUE klass, ID id, int ex) void rb_attr(VALUE klass, ID id, int read, int write, int ex) { - const char *name; ID attriv; VALUE aname; rb_method_flag_t noex; @@ -836,15 +835,13 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex) } if (!rb_is_local_id(id) && !rb_is_const_id(id)) { - rb_name_error(id, "invalid attribute name `%s'", rb_id2name(id)); + rb_name_error_str(id, "invalid attribute name `%"PRIsVALUE"'", QUOTE_ID(id)); } - name = rb_id2name(id); - if (!name) { + aname = rb_id2str(id); + if (NIL_P(aname)) { rb_raise(rb_eArgError, "argument needs to be symbol or string"); } - aname = rb_sprintf("@%s", name); - rb_enc_copy(aname, rb_id2str(id)); - attriv = rb_intern_str(aname); + attriv = rb_intern_str(rb_sprintf("@%"PRIsVALUE, aname)); if (read) { rb_add_method(klass, id, VM_METHOD_TYPE_IVAR, (void *)attriv, noex); } |