* time.c (num_exact): should not accept strings as operands, even
though they respond to #to_r. ideally, strict rational conversion should be done by a method like #to_rational, not #to_r. [ruby-core:23729] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4cec4edd0b
commit
2c2cf71b04
@ -3,6 +3,13 @@ Fri Dec 4 15:50:18 2009 Shugo Maeda <shugo@ruby-lang.org>
|
|||||||
* vm_eval.c (yield_under): does not yield self, and passes blockptr
|
* vm_eval.c (yield_under): does not yield self, and passes blockptr
|
||||||
instead of &block to vm_cref_push(). [ruby-dev:39833]
|
instead of &block to vm_cref_push(). [ruby-dev:39833]
|
||||||
|
|
||||||
|
Fri Dec 4 15:15:43 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* time.c (num_exact): should not accept strings as operands, even
|
||||||
|
though they respond to #to_r. ideally, strict rational
|
||||||
|
conversion should be done by a method like #to_rational, not #to_r.
|
||||||
|
[ruby-core:23729]
|
||||||
|
|
||||||
Fri Dec 4 13:10:23 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
Fri Dec 4 13:10:23 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||||
|
|
||||||
* ext/stringio/stringio.c (ungetc): RDoc updated. trunk allows
|
* ext/stringio/stringio.c (ungetc): RDoc updated. trunk allows
|
||||||
|
7
time.c
7
time.c
@ -214,19 +214,22 @@ num_exact(VALUE v)
|
|||||||
v = rb_convert_type(v, T_RATIONAL, "Rational", "to_r");
|
v = rb_convert_type(v, T_RATIONAL, "Rational", "to_r");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_STRING:
|
||||||
case T_NIL:
|
case T_NIL:
|
||||||
goto typeerror;
|
goto typeerror;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
VALUE tmp;
|
VALUE tmp;
|
||||||
if (!NIL_P(tmp = rb_check_convert_type(v, T_RATIONAL, "Rational", "to_r")))
|
if (!NIL_P(tmp = rb_check_convert_type(v, T_RATIONAL, "Rational", "to_r"))) {
|
||||||
|
if (rb_respond_to(v, rb_intern("to_str"))) goto typeerror;
|
||||||
v = tmp;
|
v = tmp;
|
||||||
|
}
|
||||||
else if (!NIL_P(tmp = rb_check_to_integer(v, "to_int")))
|
else if (!NIL_P(tmp = rb_check_to_integer(v, "to_int")))
|
||||||
v = tmp;
|
v = tmp;
|
||||||
else {
|
else {
|
||||||
typeerror:
|
typeerror:
|
||||||
rb_raise(rb_eTypeError, "can't convert %s into an exact number",
|
rb_raise(rb_eTypeError, "can't convert %s into an exact number",
|
||||||
rb_obj_classname(v));
|
NIL_P(v) ? "nil" : rb_obj_classname(v));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user