From 4af0ea55ca2233871b687bdc9a4ffbfffea1263d Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 25 Oct 2024 19:20:00 +0200 Subject: [PATCH] Instantiate Parser with a kwsplat Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs. So if json_pure 2.7.4 is loaded with `json <= 2.7.2` (or stdlib) it blows up. Ref: https://github.com/ruby/json/issues/650 Fix: https://github.com/ruby/json/issues/651 --- CHANGES.md | 2 ++ lib/json/common.rb | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 0349d1261..4eacb2384 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ # Changes +* Workaround another issue caused by conflicting versions of both `json_pure` and `json` being loaded. + ### 2024-10-25 (2.7.4) * Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490. diff --git a/lib/json/common.rb b/lib/json/common.rb index bb37820a7..d79c50245 100644 --- a/lib/json/common.rb +++ b/lib/json/common.rb @@ -219,7 +219,12 @@ def parse(source, opts = nil) if opts.nil? Parser.new(source).parse else - Parser.new(source, opts).parse + # NB: The ** shouldn't be required, but we have to deal with + # different versions of the `json` and `json_pure` gems being + # loaded concurrently. + # Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs. + # Ref: https://github.com/ruby/json/issues/650 + Parser.new(source, **opts).parse end end