ruby-changes:16491
From: yugui <ko1@a...>
Date: Tue, 29 Jun 2010 23:48:30 +0900 (JST)
Subject: [ruby-changes:16491] Ruby:r28481 (ruby_1_9_2): merges r28361 from trunk into ruby_1_9_2.
yugui 2010-06-29 23:48:12 +0900 (Tue, 29 Jun 2010) New Revision: 28481 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28481 Log: merges r28361 from trunk into ruby_1_9_2. -- * ext/psych/lib/psych/visitors/to_ruby.rb (resolve_klass): fix the exception message when attempting to load an unknown class. Thanks nobu! [ruby-dev:41399] * test/psych/test_psych.rb: test for the exception message Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/ext/psych/lib/psych/visitors/to_ruby.rb branches/ruby_1_9_2/test/psych/test_psych.rb Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 28480) +++ ruby_1_9_2/ChangeLog (revision 28481) @@ -1,3 +1,11 @@ +Sat Jun 19 03:35:58 2010 Aaron Patterson <aaron@t...> + + * ext/psych/lib/psych/visitors/to_ruby.rb (resolve_klass): fix the + exception message when attempting to load an unknown class. Thanks + nobu! [ruby-dev:41399] + + * test/psych/test_psych.rb: test for the exception message + Fri Jun 18 01:50:21 2010 Yusuke Endoh <mame@t...> * object.c: Object#public_methods, private_methods, etc. returns Index: ruby_1_9_2/ext/psych/lib/psych/visitors/to_ruby.rb =================================================================== --- ruby_1_9_2/ext/psych/lib/psych/visitors/to_ruby.rb (revision 28480) +++ ruby_1_9_2/ext/psych/lib/psych/visitors/to_ruby.rb (revision 28481) @@ -246,13 +246,13 @@ 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 Index: ruby_1_9_2/test/psych/test_psych.rb =================================================================== --- ruby_1_9_2/test/psych/test_psych.rb (revision 28480) +++ ruby_1_9_2/test/psych/test_psych.rb (revision 28481) @@ -14,6 +14,13 @@ end end + def test_non_existing_class_on_deserialize + e = assert_raises(ArgumentError) do + Psych.load("--- !ruby/object:NonExistent\nfoo: 1") + end + assert_equal 'undefined class/module NonExistent', e.message + end + def test_dump_stream things = [22, "foo \n", {}] stream = Psych.dump_stream(*things) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/