mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* time.c (num_exact): use to_r method only if to_int method is
available. [ruby-core:53764] [Bug #8173] reported by Hiro Asari. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									2f1e7f6a71
								
							
						
					
					
						commit
						c64f26a281
					
				
					 3 changed files with 10 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,9 @@
 | 
			
		|||
Wed Mar 27 12:45:41 2013  Tanaka Akira  <akr@fsij.org>
 | 
			
		||||
 | 
			
		||||
	* time.c (num_exact): use to_r method only if to_int method is
 | 
			
		||||
	  available.
 | 
			
		||||
	  [ruby-core:53764] [Bug #8173] reported by Hiro Asari.
 | 
			
		||||
 | 
			
		||||
Wed Mar 27 12:07:40 2013  Tanaka Akira  <akr@fsij.org>
 | 
			
		||||
 | 
			
		||||
	* test/-ext-/num2int/test_num2int.rb (test_num2ll): test LLONG_MIN,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -351,6 +351,7 @@ class TestTime < Test::Unit::TestCase
 | 
			
		|||
    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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								time.c
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								time.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -683,7 +683,9 @@ num_exact(VALUE v)
 | 
			
		|||
 | 
			
		||||
      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;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue