aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb8
-rw-r--r--test/psych/test_psych.rb7
3 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 1811a7b53f..e8c7b15666 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sat Jun 19 03:35:58 2010 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * 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@ruby-lang.org>
* gc.c (gc_lazy_sweep): clean a warning.
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index e28ac7bf87..ffff636d8e 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
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 4f78ea96d9..0d33cb1970 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -14,6 +14,13 @@ class TestPsych < Psych::TestCase
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)