Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Date._strptime raises Java exception on invalid argument #6428

@kares

Description

@kares

... while it should properly raise a Ruby TypeError, such as with MRI:

ruby -rtime -e "Time.strptime(0, '%Y-%m-%d')"

time.rb:432:in `_strptime': no implicit conversion of Integer into String (TypeError)

ruby -rtime -e "Time.strptime(nil, '%Y-%m-%d')"

time.rb:432:in `_strptime': no implicit conversion of nil into String (TypeError)

JRuby (9.2.13.0) ends up with:

        4: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:203)
        3: from org.jruby.ext.date.RubyDate$INVOKER$s$_strptime.call(RubyDate$INVOKER$s$_strptime.gen)
        2: from org.jruby.ext.date.RubyDate._strptime(RubyDate.java:1685)
        1: from org.jruby.ext.date.RubyDate.parse(RubyDate.java:1691)
Java::JavaLang::ClassCastException (org.jruby.RubyNil cannot be cast to org.jruby.RubyString)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions