Project

General

Profile

Bug #11884

Psych.load broken for OpenStruct in Ruby 2.3.0

Added by kaikuchn (Kai Kuchenbecker) almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
[ruby-core:72501]

Description

Deserialising an OpenStruct through Psych::load results in a nil error since OpenStruct now has a respond_to_missing? method whose implementation references OpenStruct's @table instance variable.

To reproduce this issue simply use Psych to dump an OpenStruct and then load it again via Psych::load. I attached an example script that does exactly this. I have also attached the error output I get when running this script.

I'm not sure whether to assign marcandre or tenderlove... Please tell me if you need any further information.

Best regards,
Kai


Files

psych_error.rb (99 Bytes) psych_error.rb Script to reproduce error kaikuchn (Kai Kuchenbecker), 12/27/2015 12:40 AM
psych_error.log (1.54 KB) psych_error.log Error output of Psych.load for OpenStruct kaikuchn (Kai Kuchenbecker), 12/27/2015 12:40 AM
syck_error.rb (101 Bytes) syck_error.rb PSchambacher (Pierre Schambacher), 04/26/2016 05:56 PM
syck_error.log (635 Bytes) syck_error.log PSchambacher (Pierre Schambacher), 04/26/2016 05:56 PM

Related issues

Related to Ruby master - Bug #13358: OpenStruct overriding allocateClosedActions
Has duplicate Ruby master - Bug #11966: YAML#load fails with OpenStruct objectClosedActions
Has duplicate Ruby master - Bug #12140: Serialization of OpenStruct objects with YAML failsClosedActions
Has duplicate Ruby master - Bug #12349: Can't load OpenStruct with Syck with Ruby 2.3.xClosedActions

Associated revisions

Revision 15960b37
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

ostruct.rb: respond_to?

  • lib/ostruct.rb (OpenStruct): make respond_to? working on just-allocated objects for workaround of Psych. [ruby-core:72501] [Bug #11884]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 53366
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

ostruct.rb: respond_to?

  • lib/ostruct.rb (OpenStruct): make respond_to? working on just-allocated objects for workaround of Psych. [ruby-core:72501] [Bug #11884]

Revision 53366
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

ostruct.rb: respond_to?

  • lib/ostruct.rb (OpenStruct): make respond_to? working on just-allocated objects for workaround of Psych. [ruby-core:72501] [Bug #11884]

Revision 53366
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

ostruct.rb: respond_to?

  • lib/ostruct.rb (OpenStruct): make respond_to? working on just-allocated objects for workaround of Psych. [ruby-core:72501] [Bug #11884]

Revision 53366
Added by nobu (Nobuyoshi Nakada) almost 4 years ago

ostruct.rb: respond_to?

  • lib/ostruct.rb (OpenStruct): make respond_to? working on just-allocated objects for workaround of Psych. [ruby-core:72501] [Bug #11884]

Revision 4c1ac0bc
Added by naruse (Yui NARUSE) over 3 years ago

merge revision(s) 53366:[Backport #11884]

    * lib/ostruct.rb (OpenStruct): make respond_to? working on
      just-allocated objects for workaround of Psych.
      [ruby-core:72501] [Bug #11884]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 54387
Added by naruse (Yui NARUSE) over 3 years ago

merge revision(s) 53366:[Backport #11884]

* lib/ostruct.rb (OpenStruct): make respond_to? working on
  just-allocated objects for workaround of Psych.
  [ruby-core:72501] [Bug #11884]

History

Updated by kaikuchn (Kai Kuchenbecker) almost 4 years ago

  • Description updated (diff)
#2

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

  • Status changed from Open to Closed

Applied in changeset r53366.


ostruct.rb: respond_to?

  • lib/ostruct.rb (OpenStruct): make respond_to? working on just-allocated objects for workaround of Psych. [ruby-core:72501] [Bug #11884]

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED
#4

Updated by marcandre (Marc-Andre Lafortune) almost 4 years ago

  • Has duplicate Bug #11966: YAML#load fails with OpenStruct object added
#5

Updated by marcandre (Marc-Andre Lafortune) over 3 years ago

  • Has duplicate Bug #12140: Serialization of OpenStruct objects with YAML fails added

Updated by naruse (Yui NARUSE) over 3 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.0.0: DONTNEED, 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE

ruby_2_3 r54387 merged revision(s) 53366.

Updated by PSchambacher (Pierre Schambacher) over 3 years ago

I'm sorry to re-open this but I'm getting a similar error with Syck and Ruby 2.3.1 just released
I attached a repro script and the log that I get when running it. Like psych, the @table instance variable of the OpenStruct isn't initialized when respond_to_missing? gets called.

#8

Updated by marcandre (Marc-Andre Lafortune) over 3 years ago

  • Has duplicate Bug #12349: Can't load OpenStruct with Syck with Ruby 2.3.x added
#9

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Related to Bug #13358: OpenStruct overriding allocate added

Also available in: Atom PDF