Giving YAML.load a non-IO object raises a Java error instead of a Ruby error
----------------------------------------------------------------------------
Key: JRUBY-1536
URL: http://jira.codehaus.org/browse/JRUBY-1536
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1b1, JRuby 1.0.2, JRuby 1.0.1, JRuby 1.0.0
Environment: OS X 10.4.10 with Java 5
Reporter: Matt Fletcher
Priority: Minor
Attachments: test_yaml_load_with_non_io_object_raises_typeerror.rb
Calling YAML.load with something like an empty hash or array raises a
java.lang.IllegalArgumentException with the text "Object: is not a legal
argument to this wrapper, cause it doesn't respond to "read"." instead of a
Ruby TypeError with the text "instance of IO needed."
A test case is attached; on JRuby 1.0.2 the bad exception is caught and handled
by Test::Unit, but on JRuby 1.1b1 it flys all the way to the top and kills the
process. The test passes in C Ruby.
Paste of the test case:
{noformat}
=================
require "test/unit"
require "yaml"
class YamlLoadTest < Test::Unit::TestCase
def test_yaml_load_with_bad_type_raises_typeerror
[[], {}].each do |not_an_IO_object|
err = assert_raise(TypeError) do
YAML.load(not_an_IO_object)
end
assert_match("instance of IO needed", err.message)
end
end
end
=================
{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email