string.c: preserve encoding of global variable
* string.c (rb_str_setter): preserve encoding of global variable name in error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b58802a3c1
commit
25bab786cb
@ -1,3 +1,8 @@
|
|||||||
|
Mon Nov 24 02:03:40 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_setter): preserve encoding of global variable
|
||||||
|
name in error message.
|
||||||
|
|
||||||
Mon Nov 24 02:03:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Nov 24 02:03:30 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* iseq.c (rb_insn_operand_intern): preserve encoding of method
|
* iseq.c (rb_insn_operand_intern): preserve encoding of method
|
||||||
|
2
string.c
2
string.c
@ -7998,7 +7998,7 @@ void
|
|||||||
rb_str_setter(VALUE val, ID id, VALUE *var)
|
rb_str_setter(VALUE val, ID id, VALUE *var)
|
||||||
{
|
{
|
||||||
if (!NIL_P(val) && !RB_TYPE_P(val, T_STRING)) {
|
if (!NIL_P(val) && !RB_TYPE_P(val, T_STRING)) {
|
||||||
rb_raise(rb_eTypeError, "value of %s must be String", rb_id2name(id));
|
rb_raise(rb_eTypeError, "value of %"PRIsVALUE" must be String", rb_id2str(id));
|
||||||
}
|
}
|
||||||
*var = val;
|
*var = val;
|
||||||
}
|
}
|
||||||
|
@ -2056,6 +2056,11 @@ class TestString < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_setter
|
def test_setter
|
||||||
assert_raise(TypeError) { $/ = 1 }
|
assert_raise(TypeError) { $/ = 1 }
|
||||||
|
name = "\u{5206 884c}"
|
||||||
|
assert_separately([], <<-"end;") # do
|
||||||
|
alias $#{name} $/
|
||||||
|
assert_raise_with_message(TypeError, /\\$#{name}/) { $#{name} = 1 }
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_id
|
def test_to_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user