error.c: check argument of Warning.warn
* error.c (rb_warning_s_warn): the argument must be an ASCII-compatible string. [ruby-core:77430] [Bug #12793] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3d2e45d319
commit
d28bac1cae
@ -1,3 +1,8 @@
|
|||||||
|
Wed Sep 28 00:21:00 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* error.c (rb_warning_s_warn): the argument must be an
|
||||||
|
ASCII-compatible string. [ruby-core:77430] [Bug #12793]
|
||||||
|
|
||||||
Tue Sep 27 23:22:31 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Sep 27 23:22:31 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (symbol, dsym, parser_set_number_literal): set state to
|
* parse.y (symbol, dsym, parser_set_number_literal): set state to
|
||||||
|
2
error.c
2
error.c
@ -152,6 +152,8 @@ ruby_only_for_internal_use(const char *func)
|
|||||||
static VALUE
|
static VALUE
|
||||||
rb_warning_s_warn(VALUE mod, VALUE str)
|
rb_warning_s_warn(VALUE mod, VALUE str)
|
||||||
{
|
{
|
||||||
|
Check_Type(str, T_STRING);
|
||||||
|
rb_must_asciicompat(str);
|
||||||
rb_write_error_str(str);
|
rb_write_error_str(str);
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
@ -940,4 +940,16 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||||||
remove_method :warn2
|
remove_method :warn2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_warning_warn_invalid_argument
|
||||||
|
assert_raise(TypeError) do
|
||||||
|
::Warning.warn nil
|
||||||
|
end
|
||||||
|
assert_raise(TypeError) do
|
||||||
|
::Warning.warn 1
|
||||||
|
end
|
||||||
|
assert_raise(Encoding::CompatibilityError) do
|
||||||
|
::Warning.warn "\x00a\x00b\x00c".force_encoding("utf-16be")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user