[前][次][番号順一覧][スレッド一覧]

ruby-changes:28246

From: nagachika <ko1@a...>
Date: Mon, 15 Apr 2013 00:45:57 +0900 (JST)
Subject: [ruby-changes:28246] nagachika:r40298 (ruby_2_0_0): merge revision(s) 39967: [Backport #8193]

nagachika	2013-04-15 00:45:42 +0900 (Mon, 15 Apr 2013)

  New Revision: 40298

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40298

  Log:
    merge revision(s) 39967: [Backport #8193]
    
    * time.c (num_exact): use to_r method only if to_int method is
      available.
      [ruby-core:53764] [Bug #8173] reported by Hiro Asari.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/test/ruby/test_time.rb
    branches/ruby_2_0_0/time.c
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/time.c
===================================================================
--- ruby_2_0_0/time.c	(revision 40297)
+++ ruby_2_0_0/time.c	(revision 40298)
@@ -683,7 +683,9 @@ num_exact(VALUE v) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/time.c#L683
 
       default:
         if ((tmp = rb_check_funcall(v, rb_intern("to_r"), 0, NULL)) != Qundef) {
-            if (rb_respond_to(v, rb_intern("to_str"))) goto typeerror;
+            /* test to_int method availability to reject non-Numeric
+             * objects such as String, Time, etc which have to_r method. */
+            if (!rb_respond_to(v, rb_intern("to_int"))) goto typeerror;
             v = tmp;
             break;
         }
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 40297)
+++ ruby_2_0_0/ChangeLog	(revision 40298)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Apr 15 00:25:00 2013  Tanaka Akira  <akr@f...>
+
+	* time.c (num_exact): use to_r method only if to_int method is
+	  available.
+	  [ruby-core:53764] [Bug #8173] reported by Hiro Asari.
+
 Mon Apr 15 00:22:09 2013  Shota Fukumori  <her@s...>
 
 	* ext/objspace/objspace.c: Fix typo in doc. Patch by Sho Hashimoto.
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 40297)
+++ ruby_2_0_0/version.h	(revision 40298)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2013-04-15"
-#define RUBY_PATCHLEVEL 133
+#define RUBY_PATCHLEVEL 134
 
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 4
Index: ruby_2_0_0/test/ruby/test_time.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_time.rb	(revision 40297)
+++ ruby_2_0_0/test/ruby/test_time.rb	(revision 40298)
@@ -351,6 +351,7 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_time.rb#L351
     end
     assert_raise(ArgumentError) { Time.gm(2000, 1, 1, 0, 0, -(2**31), :foo, :foo) }
     o = Object.new
+    def o.to_int; 0; end
     def o.to_r; nil; end
     assert_raise(TypeError) { Time.gm(2000, 1, 1, 0, 0, o, :foo, :foo) }
     def o.to_r; ""; end

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r39967


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]