Make parser's #inspect work in non-main Ractors - #262
Open
y-yagi wants to merge 1 commit into
Open
Conversation
`URI::RFC3986_PARSER.inspect` and `URI::RFC2396_PARSER.inspect` raised
`Ractor::IsolationError` when called from a non-main Ractor:
Ractor.new { URI::RFC3986_PARSER.inspect }.value
#=> can not access class variables from non-main Ractors
# (@@to_s from URI::RFC3986_Parser)
Ractor.new { URI::RFC2396_PARSER.inspect }.value
#=> can not access non-shareable objects in constant
# URI::RFC2396_Parser::TO_S by non-main ractor
Both parsers kept `Kernel.instance_method(:to_s)` at the class level, in a
class variable and in a constant respectively. An `UnboundMethod` is not
shareable, so neither can be read from a non-main Ractor.
`UnboundMethod` is Ractor-shareable only Ruby 4.0. And, parser's inspect only for
debug and performance isn't so important, I think
So this commit changes not to held the method and just call it in the
method.
y-yagi
marked this pull request as ready for review
September 9, 2026 09:55
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.
URI::RFC3986_PARSER.inspectandURI::RFC2396_PARSER.inspectraisedRactor::IsolationErrorwhen called from a non-main Ractor:Both parsers kept
Kernel.instance_method(:to_s)at the class level, in a class variable and in a constant respectively. AnUnboundMethodis not shareable, so neither can be read from a non-main Ractor.UnboundMethodis Ractor-shareable only Ruby 4.0. And, parser's inspect only for debug and performance isn't so important, I thinkSo this commit changes not to held the method and just call it in the method.