[前][次][番号順一覧][スレッド一覧]

ruby-changes:16381

From: tenderlove <ko1@a...>
Date: Sat, 19 Jun 2010 03:39:12 +0900 (JST)
Subject: [ruby-changes:16381] Ruby:r28361 (trunk): * ext/psych/lib/psych/visitors/to_ruby.rb (resolve_klass): fix the

tenderlove	2010-06-19 03:38:19 +0900 (Sat, 19 Jun 2010)

  New Revision: 28361

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28361

  Log:
    * 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:
    trunk/ChangeLog
    trunk/ext/psych/lib/psych/visitors/to_ruby.rb
    trunk/test/psych/test_psych.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28360)
+++ ChangeLog	(revision 28361)
@@ -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 10:37:46 2010  NARUSE, Yui  <naruse@r...>
 
 	* gc.c (gc_lazy_sweep): clean a warning.
Index: ext/psych/lib/psych/visitors/to_ruby.rb
===================================================================
--- ext/psych/lib/psych/visitors/to_ruby.rb	(revision 28360)
+++ ext/psych/lib/psych/visitors/to_ruby.rb	(revision 28361)
@@ -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: test/psych/test_psych.rb
===================================================================
--- test/psych/test_psych.rb	(revision 28360)
+++ test/psych/test_psych.rb	(revision 28361)
@@ -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/

[前][次][番号順一覧][スレッド一覧]