Actions
Bug #12793
closedWarning.warn with non-string object
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-09-27 trunk 56273) [x86_64-linux]
Description
Warning.warn
with non-string argument causes SEGV.
For example, Warning.warn nil
.
Updated by nobu (Nobuyoshi Nakada) almost 8 years ago
- Status changed from Open to Closed
Applied in changeset r56274.
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]
Updated by znz (Kazuhiro NISHIYAMA) almost 8 years ago
Kernel#warn
accepts nil
and 1
, but Warning.warn
raises TypeError
.
Is this difference expected?
% ruby -ve 'warn nil; Warning.warn nil'
ruby 2.4.0dev (2016-09-28 trunk 56281) [x86_64-linux]
-e:1:in `warn': wrong argument type nil (expected String) (TypeError)
from -e:1:in `<main>'
% ruby -ve 'warn 1; Warning.warn 1'
ruby 2.4.0dev (2016-09-28 trunk 56281) [x86_64-linux]
1
-e:1:in `warn': wrong argument type Integer (expected String) (TypeError)
from -e:1:in `<main>'
Updated by nobu (Nobuyoshi Nakada) almost 8 years ago
While Kernel#warn
should be generous since it is a public API,
Warning.warn
is a method called by the internal and should be strict.
Actions
Like0
Like0Like0Like0