Project

General

Profile

Actions

Bug #16501

closed

Support marshaling of ruby2_keywords flag

Added by mame (Yusuke Endoh) about 4 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:96777]

Description

This patch makes Marshal.dump and load aware of ruby2_keywords flag.

https://github.com/ruby/ruby/pull/2830

def bar(key:)
  key
end

ruby2_keywords def foo(*args)
  args = Marshal.load(Marshal.dump(args))
  bar(*args)
end

foo(key: 42) #=> 42

Honestly, I'm not fully convinced if this is really needed. It would be helpful for applications and libraries that serializes the whole arguments by using Marshal, e.g., drb. (Currently, drb does not support keyword separation.) But I'm unsure how many applications does so; ActiveJob and Sidekiq use their own dedicated serialization mechanism based on JSON. This patch does not help them, and they should use #16486 to support ruby2_keywords flag. I'd like to hear opinions.

Updated by Eregon (Benoit Daloze) about 4 years ago

Makes sense to me that Marshal knows how to preserve that flag.
(Sidekiq used Marshal in previous versions, but switched to a manual copy for efficiency)

Updated by matz (Yukihiro Matsumoto) about 4 years ago

I agree. Accepted.

Matz.

Actions #3

Updated by mame (Yusuke Endoh) about 4 years ago

  • Status changed from Open to Closed

Applied in changeset git|b23fd59cbb3f097bcd559d0c85a86ff7a1eeeb7e.


marshal.c: Support dump and load of a Hash with the ruby2_keywords flag

It is useful for a program that dumps and load arguments (like drb).
In future, they should deal with both positional arguments and keyword
ones explicitly, but until ruby2_keywords is deprecated, it is good to
support the flag in marshal.

The implementation is similar to String's encoding; it is dumped as a
hidden instance variable.

[Feature #16501]

Updated by mame (Yusuke Endoh) almost 4 years ago

  • Tracker changed from Feature to Bug
  • Backport set to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED

This might not be a bug, but the change is needed for #16634 2339be74e737b4c5f5330f845af2e7db0c7450e1, so please backport to 2.7.

Updated by nagachika (Tomoyuki Chikanaga) over 3 years ago

  • Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE

ruby_2_7 ae804b143455075687c8b4a401fba48fda72a217 merged revision(s) b23fd59cbb3f097bcd559d0c85a86ff7a1eeeb7e.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0