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
The symbolize_names
keyword argument breaks Psych.load / API conflicts
#340
Comments
Another angle to the current situation: The API has (accidentally) started to evolve in such a way that various methods that do essentially the same thing (viz. reading yaml) do not provide the same set of options (although these options make sense for all of them). And the crucial problem is that it will not be possible to implement those options for all methods without API changes. That‘s not a good basis for going into a new major release, IMO. E.g. |
Any thought on this and related discussions? |
symbolize_names
keyword argument breaks Psych.loadsymbolize_names
keyword argument breaks Psych.load / API conflicts
See NEWS file for this update details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I assume this issue will not be consdered for Psych 3.0 / Ruby 2.5...? |
I'm ok with current API implementation. Because Hash and keyword argument will be changed/broke Ruby 2.6 or 3.0. see. https://bugs.ruby-lang.org/issues/14183 We should consider again at Ruby 2.6/3.0 for psych-4.0.0 |
I still don't get your point and what you want to fix. We can't discuss in a reasonable way until I understand them. Some assumptions in my mind to confirm what you think:
Given that assumptions, here are my comments for your points:
|
@k0kubun Yes, I think I can agree with these assumptions; but I still don't get what's so difficult to understand. Are you really implicating that this kind of API is by intention (rather than a pure oversight): Psych.load_file(f, {})
# but:
Psych.load("", "filename", Psych::FALLBACK.new({})) Note that it was never mentioned in the relevant issues/PRs, nor added as a test case, nor documented. Also, The intended behaviour most certainly was (and I really cannot imagine anyone would argue against this): Psych.load_file(f, {})
Psych.load("", "filename", {}) Furthermore, it should be possible to provide both the If you want to call fixing an undocumented, strange behaviour a breaking change rather than a bug fix, well, let's do that. Personally, I would love to have all those positional optional arguments converted to keyword arguments; but I can not at all judge what the impact of such a change would be and whether it's advisable. |
Okay, now it seems that I understand what you've thought.
Yes, and so this kind of thing depends on maintainers' decision. I leave it for them. |
It version changed fallback option to keywoad argument on `Yaml.load` method. It break backword compatiblity. see detailed discuttion: ruby/psych#340 From: SHIBATA Hiroshi <hsbt@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Solved by #342. |
IMO this should be considered before the new option is established in the 3.0 major release.
Current call-seq of Psych.load:
The mixing of optional arguments and optional keyword argument does not play well together:
fallback
can not be set to a hash (the specifically wished use case when the option was added):The provided empty hash is ignored as fallback return value, and the default
false
is returned instead.The hash is only used when the
symbolize_names
keyword argument is also provided. (However, currently this will cause an exception due to an implementation bug in the handling of the fallback argument; a fix is provided in #339.)Possible solutions to this problem:
fallback: false
); in this case it would be necessary to check whether this might cause similar problems in other methods that already have the fallback option or should have it (e.g.safe_load
would be a candidate for also having this option)The text was updated successfully, but these errors were encountered: