Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

raise ArgumentError when IO.new/IO.open last argument is not a hash or nil #768

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  spec/tags/1.9/ruby/core/io/new_tags.txt
@@ -1,4 +1,3 @@
fails:IO.new raises an error if passed binary/text mode two ways
fails:IO.new sets external encoding to binary with :binmode option
-fails:IO.new raises ArgumentError if not passed a hash or nil for options
fails:IO.new accepts an :autoclose option
View
1  spec/tags/1.9/ruby/core/io/open_tags.txt
@@ -1,4 +1,3 @@
fails:IO.open raises an error if passed binary/text mode two ways
fails:IO.open sets external encoding to binary with :binmode option
-fails:IO.open raises ArgumentError if not passed a hash or nil for options
fails:IO.open accepts an :autoclose option
View
4 src/org/jruby/RubyIO.java
@@ -859,6 +859,10 @@ public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, I
private IRubyObject initializeCommon19(ThreadContext context, int fileno, IRubyObject vmodeArg, IRubyObject options) {
Ruby runtime = context.runtime;
+ if(options != null && !options.isNil() && !(options instanceof RubyHash) && !(options.respondsTo("to_hash"))) {
+ throw runtime.newArgumentError("last argument must be a hash!");
+ }
+
try {
ChannelDescriptor descriptor = ChannelDescriptor.getDescriptorByFileno(runtime.getFilenoExtMap(fileno));
Something went wrong with that request. Please try again.