New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subclassed Hash with overridden #initialize cannot be deserialized #196
Comments
See #43. We have a workaround that's less than ideal but it works. I'm assuming that Hash.new runs through C code and doesn't invoke your initialize in ruby land, hence you get (0 for 1). I'd recommend against subclassing Hash but if you have to, you can set instance variables and use a workaround like ours. |
Seems it was because I was calling |
headius
pushed a commit
to headius/psych
that referenced
this issue
Jan 8, 2020
* master: (21 commits) * ext/psych/lib/psych/visitors/to_ruby.rb: call `allocate` on hash subclasses. Fixes github.com/ruby/issues/196 * ext/psych/lib/psych/visitors/to_ruby.rb: revive hashes with ivars removed isolate task removed isolate plugin added minitest dependency into gemspec added install task into travis added ruby-head env bumping version to 2.0.8 fixed build error caused by trunk changes bumping version to 2.0.7 merging from ruby trunk backport r48512 from ruby/ruby trunk. Add changelog for 2a4d956 backport r48214 from ruby/ruby trunk. Allow dumping any BasicObject that defines #marshal_dump or #marshal_load bumping version * ext/psych/lib/psych/visitors/yaml_tree.rb: fix NameError dumping and loading. Fixes GH ruby#85. Thanks @brentdax for the patch! * test/psych/test_exception.rb: test for fix * ext/psych/lib/psych/scalar_scanner.rb: fix loading strings that look like integers but have a newline. Fixes GH ruby#189 * test/psych/test_string.rb: test for fix * ext/psych/lib/psych/visitors/to_ruby.rb: merge keys with a hash should merge the hash in to the parent. * test/psych/test_merge_keys.rb: test for change. Fixes GH ruby#202 * ext/psych/lib/psych/visitors/to_ruby.rb: quoted "<<" strings should not be treated as merge keys. * ext/psych/lib/psych/visitors/yaml_tree.rb: hashes with keys containing "<<" should roundtrip. * test/psych/test_merge_keys.rb: test for change. Fixes GH ruby#203 ... Conflicts: lib/psych/visitors/yaml_tree.rb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
YAML.load
line raisesArgumentError: wrong number of arguments (0 for 1)
.It only seems to be a problem with
Hash
descendants.Array
andString
both work as expected; I haven't bothered to test any other classes.Tested with different combinations of the following:
Backtrace (from Ruby 2.1.0/Psych 2.0.5):
The text was updated successfully, but these errors were encountered: