-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
Marcel 1.1.0 emits Ruby 3.4 deprecation warnings despite PR #123.
Reproduction
require 'marcel'
require 'stringio'
io = StringIO.new("test content")
Marcel::MimeType.for(io)Run with Ruby's verbose warnings (as Rails test suites do):
$ ruby -W2 repro.rb
/gems/marcel-1.1.0/lib/marcel/magic.rb:120: warning: literal string will be frozen in the futureRoot Cause
PR #123 fixed line 122 but missed lines 120-121:
def self.magic_match(io, method)
return magic_match(StringIO.new(io.to_s), method) unless io.respond_to?(:read)
io.binmode if io.respond_to?(:binmode) # ← line 120: triggers warning
io.set_encoding(Encoding::BINARY) if io.respond_to?(:set_encoding) # ← line 121: triggers warning
buffer = (+"").encode(Encoding::BINARY) # ← line 122: fixed by PR #123
MAGIC.send(method) { |type, matches| magic_match_io(io, matches, buffer) }
endCalling these methods on StringIO triggers Ruby 3.4's frozen string literal warnings.
Impact
Rails applications see warnings polluting test output.
Environment
- Ruby: 3.4.5
- Marcel: 1.1.0
- Trigger:
-W2flag (verbose warnings, used by Rails)
Metadata
Metadata
Assignees
Labels
No labels