Skip to content

Commit

Permalink
Merge pull request #2241 from herwinw/marshal_dump_singleton_class
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1m authored Sep 29, 2024
2 parents 6bc2160 + 962415e commit a12e271
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 1 addition & 3 deletions spec/core/marshal/dump_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ def _dump(level)
end

it "raises TypeError with a singleton Class" do
NATFIXME 'raises TypeError with a singleton Class', exception: SpecFailedException do
-> { Marshal.dump(class << self; self end) }.should raise_error(TypeError)
end
-> { Marshal.dump(class << self; self end) }.should raise_error(TypeError)
end
end

Expand Down
1 change: 1 addition & 0 deletions src/marshal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def write_hash(values)
end

def write_class(value)
raise TypeError, "singleton class can't be dumped" if value.singleton_class?
write_char('c')
write_string_bytes(value.name)
end
Expand Down

0 comments on commit a12e271

Please sign in to comment.