[ruby-core:116691] [Ruby master Bug#20263] Backport https://github.com/ruby/ruby/pull/9498 to Ruby 3.3