summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEarlopain <[email protected]>2025-05-12 17:51:05 +0200
committergit <[email protected]>2025-05-12 16:19:38 +0000
commit0c94ae048a277485aa691820277108c2335ec3d3 ()
tree11509d7bc85e2be484d0092ffc4e06f0eaac94d0
parent53a27f114afafcdfea1a6066d01c12e4dc295657 (diff)
[ruby/psych] Fix dumping `StringIO` (and potentially others) on Ruby <= 2.7
In Ruby < 3.0, the superclass of StringIO was actually already `Data`, but it doesn't have the expected shape. So, on these earlier versions it errors: > NoMethodError: undefined method `members' for #<StringIO:0x00005641dd5f2880> > vendor/bundle/ruby/2.6.0/gems/psych-5.2.5/lib/psych/visitors/yaml_tree.rb:170:in `visit_Data' This test doesn't fail on 2.7, presumably because it can pull in a newer `stringio` version. https://.com/ruby/psych/commit/0f40f56268
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb2
-rw-r--r--test/psych/test_stringio.rb14
2 files changed, 15 insertions, 1 deletions
@@ -198,7 +198,7 @@ module Psych
@emitter.end_mapping
end
- end
def visit_Struct o
tag = ['!ruby/struct', o.class.name].compact.join(':')
@@ -0,0 +1,14 @@