Skip to content

Commit 405fae0

Browse files
authored
Merge pull request #729 from Earlopain/data-stringio-conflict
Fix dumping `StringIO` (and potentially others) on Ruby <= 2.7
2 parents dbf9e36 + 0f40f56 commit 405fae0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

lib/psych/visitors/yaml_tree.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def visit_Data o
198198

199199
@emitter.end_mapping
200200
end
201-
end
201+
end unless RUBY_VERSION < "3.2"
202202

203203
def visit_Struct o
204204
tag = ['!ruby/struct', o.class.name].compact.join(':')

test/psych/test_stringio.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
require_relative 'helper'
3+
4+
module Psych
5+
class TestStringIO < TestCase
6+
# The superclass of StringIO before Ruby 3.0 was `Data`,
7+
# which can interfere with the Ruby 3.2+ `Data` dumping.
8+
def test_stringio
9+
assert_nothing_raised do
10+
Psych.dump(StringIO.new("foo"))
11+
end
12+
end
13+
end
14+
end

0 commit comments

Comments
 (0)