Repository navigation
Conversation
zcat forwards its arguments to GzipReader.new with rb_funcallv, which
does not mark the options hash as keywords. Since Ruby 3.0 the keyword
separation makes GzipReader#initialize reject it as an extra positional
argument, so the documented `options` always raised ArgumentError:
Zlib::GzipReader.zcat(io, external_encoding: "UTF-8")
# => ArgumentError: wrong number of arguments (given 2, expected 1)
Use rb_funcallv_kw with RB_PASS_CALLED_KEYWORDS, as gzfile_wrap does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zlib::GzipReader.zcat(io, options = {})is documented to take options, but passing any raises:zcatforwards its arguments toGzipReader.newwithrb_funcallv, which does not mark the trailing hash as keywords. Ruby 2.7'srb_scan_argsstill treated it as keywords (with a deprecation warning), but since the Ruby 3.0 keyword separationGzipReader#initialize(rb_scan_args(argc, argv, "1:", ...)) rejects it as an extra positional argument. The existing test only callszcatwithout options, so this went unnoticed.This uses
rb_funcallv_kw(..., RB_PASS_CALLED_KEYWORDS), asgzfile_wrapalready does forwrap/open, and adds a test forzcatwithexternal_encoding:, with and without a block.🤖 Generated with Claude Code