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

strftime crashes when passing a frozen format string and 24 hour Tod #72

Open
nathansamson opened this issue Sep 3, 2020 · 1 comment

Comments

@nathansamson
Copy link

strftime crashes when passing a frozen format string and 24 hour Tod::TimeOfDay

This can happen when using # frozen_string_literal: true and a hardcoded format string.

nathan@muon app]$ irb
irb(main):001:0> require 'tod'
=> true
irb(main):002:0> Tod::TimeOfDay.new(24).strftime('%H:%M'.freeze)
Traceback (most recent call last):
        6: from /home/nathan/.rbenv/versions/2.6.6/bin/irb:23:in `<main>'
        5: from /home/nathan/.rbenv/versions/2.6.6/bin/irb:23:in `load'
        4: from /home/nathan/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/irb-1.2.4/exe/irb:11:in `<top (required)>'
        3: from (irb):2
        2: from /home/nathan/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/tod-2.2.0/lib/tod/time_of_day.rb:92:in `strftime'
        1: from /home/nathan/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/tod-2.2.0/lib/tod/time_of_day.rb:92:in `gsub!'
FrozenError (can't modify frozen String)
irb(main):003:0> 

Note this actualyl has been fixed in latest master (2e09f11) but no release has been cut

@jackc
Copy link
Owner

jackc commented Sep 3, 2020

Yeah, you'll have to use master for now.

I haven't want to make a release with a known bug on the latest release of Rails (#65). A Rails 5.2.x point release broke something (I never found what). And when I just checked to see if Rails 6 was any better it turns out it has even more breakages (#73).

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

No branches or pull requests

2 participants