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

ruby-changes:28002

From: usa <ko1@a...>
Date: Tue, 2 Apr 2013 13:07:50 +0900 (JST)
Subject: [ruby-changes:28002] usa:r40054 (ruby_1_9_3): merge revision(s) 39967: [Backport #8194]

usa	2013-04-02 13:07:39 +0900 (Tue, 02 Apr 2013)

  New Revision: 40054

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

  Log:
    merge revision(s) 39967: [Backport #8194]
    
    * 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_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/test/ruby/test_time.rb
    branches/ruby_1_9_3/time.c
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/time.c
===================================================================
--- ruby_1_9_3/time.c	(revision 40053)
+++ ruby_1_9_3/time.c	(revision 40054)
@@ -683,7 +683,9 @@ num_exact(VALUE v) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/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_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 40053)
+++ ruby_1_9_3/ChangeLog	(revision 40054)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Tue Apr  2 13:07:29 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.
+
 Tue Apr  2 13:01:55 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (EXTDLDFLAGS): split options for each extension
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 40053)
+++ ruby_1_9_3/version.h	(revision 40054)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 405
+#define RUBY_PATCHLEVEL 406
 
 #define RUBY_RELEASE_DATE "2013-04-02"
 #define RUBY_RELEASE_YEAR 2013
Index: ruby_1_9_3/test/ruby/test_time.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_time.rb	(revision 40053)
+++ ruby_1_9_3/test/ruby/test_time.rb	(revision 40054)
@@ -324,6 +324,7 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_time.rb#L324
     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_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r39967


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

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