Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time.parse should coerce argument into a String #3811

hone opened this issue Apr 19, 2016 · 1 comment

Time.parse should coerce argument into a String #3811

hone opened this issue Apr 19, 2016 · 1 comment


Copy link

hone commented Apr 19, 2016


$ jruby -v
jruby (2.2.3) 2016-01-26 7bee00d OpenJDK 64-Bit Server VM 25.66-b17 on 1.8.0_66-internal-b17 +indy +jit [linux-amd64]
$ uname -a
Linux x220 4.2.0-35-generic #40-Ubuntu SMP Tue Mar 15 22:15:45 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

When calling Time.parse in MRI, it coerces the object into a String. For instance, in the syslog-parser code, it passes an object that can be coerced into a string and expects it to work.

Here's a simple repro case:

class Foo
  def to_str
    puts "coerced"

require 'time'
puts Time.parse(
$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
$ ruby test_time.rb
2016-04-19 14:32:42 -0500

Actual Behavior

In JRuby, it doesn't coerce the argument passed in.

$ jruby test_time.rb 
NoMethodError: undefined method `gsub!' for #<Foo:0x305fd85d>
  _parse at /home/hone/.rvm/rubies/jruby-
   parse at /home/hone/.rvm/rubies/jruby-
   <top> at test_time.rb:9

/cc @jkutner

@hone hone changed the title Time.pares should coerce argument into a String Time.parse should coerce argument into a String Apr 19, 2016
hone added a commit to hone/syslog-parser that referenced this issue Apr 19, 2016
@enebo enebo closed this as completed in 8c8be19 Apr 19, 2016
@enebo enebo added this to the JRuby milestone Apr 19, 2016
Copy link

enebo commented Apr 19, 2016

This fix was to modify our still pure-Ruby version of date/format.rb. MRI has converted this to a native C ext which likely means there might be some other new features we have not kept track of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants