json_pure 2.7.3 → 2.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '028937ab43af8f1ada9a531711dad5b787350f4422ac24d8c611646a016aba28'
4
- data.tar.gz: 774ccaced1f1bec5adc3088caabe6667b16efaca072e29a497608c38b2db39a8
3
+ metadata.gz: 859e40f5bfa7da73a90576204b5c49d6f42b9f2ca903239ecea54ec7a781fdc4
4
+ data.tar.gz: e38d6c5db98da6416dbb75746621aa7b7d3bd7e8f8c62042eef6e15e9ecf5f65
5
5
  SHA512:
6
- metadata.gz: 6a4b99d6eb69a794332edbf4dfc3b1466bff0698eb4596222b9c3c8eab5f84f785bc6ac63dacdc20c049cdec2b643cb083bbab7eaa139aab88cfa4e3cdab2f85
7
- data.tar.gz: 767dfddc4f6c6de51b78c29b8dd62671a7838a6dcdf6750db21cdce706c747ddff197a23dbb69696b3d4da4380b2c402e83d517fa298226ebab7a3927d28ac60
6
+ metadata.gz: 3569ecd696382dbf173955fcfa9f49f3452a2d8b45bf29dcad6cd22ee0ac67bc8a6359ca548ae5367ca93cd02af4515b7e35ac213b5989658ad3133815fbece3
7
+ data.tar.gz: 6a23ba9fba6317c04f58c0d03a81b9d85aa8c2f5f8ec585cdfe9b6e97dc5f7994cfb3ef52749b4575857057f1cf803fb29936571f0d20f7b99e17828fa7d954b
data/CHANGES.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changes
2
2
 
3
+ ### 2024-10-25 (2.7.5)
4
+
5
+ * Fix a memory leak when `#to_json` methods raise an exception.
6
+ * Gracefully handle formatting configs being set to `nil` instead of `""`.
7
+ * Workaround another issue caused by conflicting versions of both `json_pure` and `json` being loaded.
8
+
9
+ ### 2024-10-25 (2.7.4)
10
+
11
+ * Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490.
12
+ This bug would cause some gems with native extension to fail during compilation.
13
+ * Workaround different versions of `json` and `json_pure` being loaded (not officially supported).
14
+ * Make `json_pure` Ractor compatible.
15
+
3
16
  ### 2024-10-24 (2.7.3)
4
17
 
5
18
  * Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
data/lib/json/common.rb CHANGED
@@ -219,7 +219,12 @@ module JSON
219
219
  if opts.nil?
220
220
  Parser.new(source).parse
221
221
  else
222
- Parser.new(source, opts).parse
222
+ # NB: The ** shouldn't be required, but we have to deal with
223
+ # different versions of the `json` and `json_pure` gems being
224
+ # loaded concurrently.
225
+ # Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs.
226
+ # Ref: https://github.com/ruby/json/issues/650
227
+ Parser.new(source, **opts).parse
223
228
  end
224
229
  end
225
230
 
data/lib/json/ext.rb CHANGED
@@ -15,9 +15,6 @@ module JSON
15
15
  else
16
16
  require 'json/ext/parser'
17
17
  require 'json/ext/generator'
18
- unless RUBY_ENGINE == 'jruby'
19
- require 'json/ext/generator/state'
20
- end
21
18
  $DEBUG and warn "Using Ext extension for JSON."
22
19
  JSON.parser = Parser
23
20
  JSON.generator = Generator
@@ -239,13 +239,13 @@ module JSON
239
239
  end
240
240
 
241
241
  # NOTE: If adding new instance variables here, check whether #generate should check them for #generate_json
242
- @indent = opts[:indent] if opts.key?(:indent)
243
- @space = opts[:space] if opts.key?(:space)
244
- @space_before = opts[:space_before] if opts.key?(:space_before)
245
- @object_nl = opts[:object_nl] if opts.key?(:object_nl)
246
- @array_nl = opts[:array_nl] if opts.key?(:array_nl)
247
- @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
248
- @ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
242
+ @indent = opts[:indent] || '' if opts.key?(:indent)
243
+ @space = opts[:space] || '' if opts.key?(:space)
244
+ @space_before = opts[:space_before] || '' if opts.key?(:space_before)
245
+ @object_nl = opts[:object_nl] || '' if opts.key?(:object_nl)
246
+ @array_nl = opts[:array_nl] || '' if opts.key?(:array_nl)
247
+ @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
248
+ @ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
249
249
  @depth = opts[:depth] || 0
250
250
  @buffer_initial_length ||= opts[:buffer_initial_length]
251
251
 
@@ -148,25 +148,25 @@ module JSON
148
148
  end
149
149
 
150
150
  # Unescape characters in strings.
151
- UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
152
- UNESCAPE_MAP.update({
153
- ?" => '"',
154
- ?\\ => '\\',
155
- ?/ => '/',
156
- ?b => "\b",
157
- ?f => "\f",
158
- ?n => "\n",
159
- ?r => "\r",
160
- ?t => "\t",
161
- ?u => nil,
162
- })
151
+ UNESCAPE_MAP = {
152
+ '"' => '"',
153
+ '\\' => '\\',
154
+ '/' => '/',
155
+ 'b' => "\b",
156
+ 'f' => "\f",
157
+ 'n' => "\n",
158
+ 'r' => "\r",
159
+ 't' => "\t",
160
+ 'u' => nil,
161
+ }.freeze
163
162
 
164
163
  STR_UMINUS = ''.respond_to?(:-@)
165
164
  def parse_string
166
165
  if scan(STRING)
167
166
  return '' if self[1].empty?
168
- string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
169
- if u = UNESCAPE_MAP[$&[1]]
167
+ string = self[1].gsub(%r{(?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff])}n) do |c|
168
+ k = $&[1]
169
+ if u = UNESCAPE_MAP.fetch(k) { k.chr }
170
170
  u
171
171
  else # \uXXXX
172
172
  bytes = ''.b
data/lib/json/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSON
4
- VERSION = '2.7.3'
4
+ VERSION = '2.7.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_pure
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.3
4
+ version: 2.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-24 00:00:00.000000000 Z
11
+ date: 2024-10-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a JSON implementation in pure Ruby.
14
14
  email: flori@ping.de