From: "mame (Yusuke Endoh)" Date: 2012-11-08T00:44:23+09:00 Subject: [ruby-dev:46448] [ruby-trunk - Bug #7301][Assigned] URI::FTP.new2()の引数typecodeを省略するとNoMethodErrorが発生します。 Issue #7301 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to mame (Yusuke Endoh) Target version set to 2.0.0 報告ありがとうございます。 生まれてから 10 年以上このままだったっぽいですね。このメソッド本当に必要なのか? とりあえず最低限と思われるパッチを入れておきます。 diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb index 971684a..6cb9782 100644 --- a/lib/uri/ftp.rb +++ b/lib/uri/ftp.rb @@ -54,7 +54,7 @@ module URI # Arguments are user, password, host, port, path, typecode, # and arg_check, in that order. def self.new2(user, password, host, port, path, - typecode = nil, arg_check = true) + typecode = "", arg_check = true) typecode = nil if typecode.size == 0 if typecode && !TYPECODE.include?(typecode) raise ArgumentError, -- Yusuke Endoh ---------------------------------------- Bug #7301: URI::FTP.new2()の引数typecodeを省略するとNoMethodErrorが発生します。 https://bugs.ruby-lang.org/issues/7301#change-32573 Author: shi-mo (Yoshifumi Shimono) Status: Assigned Priority: Normal Assignee: mame (Yusuke Endoh) Category: Target version: 2.0.0 ruby -v: ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux] URI::FTP.new2()の引数typecodeを省略するとNoMethodErrorが発生します。 ---------------------------- $ cat nil-typecode.rb # encoding: utf-8 require 'uri' URI::FTP.new2('anonymous', 'anonymous', 'ftp.ubuntu.com', 21, '/') $ ruby -v nil-typecode.rb ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux] /home/shimono/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/uri/ftp.rb:58:in `new2': undefined method `size' for nil:NilClass (NoMethodError) from nil-typecode.rb:5:in `
' $ ---------------------------- リファレンスマニュアルの説明(http://doc.okkez.net/static/192/class/URI=3a=3aFTP.html)と関数定義(lib/uri/ftp.rb)を見ると、この引数を省略しても例外は発生すべきでないように思えます。 > def self.new2(user, password, host, port, path, > typecode = nil, arg_check = true) -- http://bugs.ruby-lang.org/