# \[trunk:bug\] Psych raises an exception with diffrent name class

**URL:** <https://www.ruby-forum.com/t/trunk-bug-psych-raises-an-exception-with-diffrent-name-class/189078>\
**Category:** Development\
**Created:** [May 24, 2010, 5:27am UTC](https://www.ruby-forum.com/t/trunk-bug-psych-raises-an-exception-with-diffrent-name-class/189078 "2010-05-24T05:27:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [May 24, 2010, 5:27am UTC](https://www.ruby-forum.com/t/trunk-bug-psych-raises-an-exception-with-diffrent-name-class/189078/1 "2010-05-24T05:27:52Z")

</div>

e$B$J$+$@$G$9!#e(B

e$B0J2\<$N$h$&$K!"e(BFooe$B$,;XDj$5$l$F$$$k$N$K%a%C%;!\<%8$G$Oe(BStruct::Fooe$B$,e(B  
e$B$J$$$H$$$&$3$H$K$J$C$F$$$^$9!#e(B

$ ./ruby -v -rpsych -ryaml -e ‘p((YAML.load("— !ruby/object:Foo\nfoo:  
1") rescue $!.message))’  
ruby 1.9.3dev (2010-05-24 trunk 27985) [i386-darwin9.0]  
“undefined class/module Struct::Foo”

e$B85$NL\>A0$r\<($9$Y$-$G$O$J$$$G$7$g$&$+!#e(B

diff --git a/ext/psych/lib/psych/visitors/to\_ruby.rb  
b/ext/psych/lib/psych/visitors/to\_ruby.rb  
index e28ac7b…ffff636 100644  
— a/ext/psych/lib/psych/visitors/to\_ruby.rb  
+++ b/ext/psych/lib/psych/visitors/to\_ruby.rb  
@@ -246,13 +246,13 @@ module Psych

```
     begin
       path2class(name)

```

- 

```
   rescue ArgumentError => ex

```

- 

```
     name = "Struct::#{name}"

```

- 

```
   rescue ArgumentError, NameError => ex
     unless retried

```

- 

```
       retried = true

```

- 

```
       name = "Struct::#{name}"

```

- 

```
       retried = ex
       retry
     end

```

- 

```
     raise ex

```

- 

```
     raise retried
   end
 end

```

end
