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

[email protected]$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