[MacRuby] #928: MacRuby throws an exception of "undefined method `size' for nil:NilClass'" with Date.httpdate.

MacRuby ruby-noreply at macosforge.org
Sun Oct 3 23:56:20 PDT 2010


#928: MacRuby throws an exception of "undefined method `size' for nil:NilClass'"
with Date.httpdate.
----------------------------------+-----------------------------------------
 Reporter:  watson1978@…          |       Owner:  lsansonetti@…        
     Type:  defect                |      Status:  new                  
 Priority:  major                 |   Milestone:                       
Component:  MacRuby               |    Keywords:                       
----------------------------------+-----------------------------------------
 Test Script:
 {{{
 #!ruby
 require 'date'

 h = Date.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
 p h
 }}}

 Result:
 {{{
 $ macruby test_httpdate.rb
 undefined method `size' for nil:NilClass (NoMethodError)
 }}}

 Patch:
 {{{
 #!diff
 diff --git a/lib/date/format.rb b/lib/date/format.rb
 index 90e3c76..efbf4c8 100644
 --- a/lib/date/format.rb
 +++ b/lib/date/format.rb
 @@ -1182,7 +1182,7 @@ class Date
         \d{2}:\d{2}(:\d{2})?\s*
         (?:[-+]\d{4}|ut|gmt|e[sd]t|c[sd]t|m[sd]t|p[sd]t|[a-ik-z])\s*\z/iox
 =~ str
        e = _parse(str, false)
 -      if $1.size < 4
 +      if (($1.nil?) || ($1.size < 4))
         if e[:year] < 50
           e[:year] += 2000
         elsif e[:year] < 1000
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/928>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list