Project

General

Profile

Actions

Bug #3830

closed

ruby 1.9.2 で Net::Telnet の close が undefined method となり実行できない

Added by khiker (Kiyoto HAMANO) over 13 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
Backport:

Description

=begin
濱野と申します。
ruby-list:47391 からはじまるスレッドで尋ねた Ruby 1.9.2-p0 における
Net::Telenet の不具合について報告させて頂きます。

ruby-1.9.2-p0 で Net::Telnet クラスを使っていたところ、close を実
行しようとしたところ、undefined method と言われる現象に遭遇しまし
た。

ruby-list で尋ねたところ、原因は、SimpleDelegator をやめてしまった
ので @sock に委譲していたメソッドが使えなくなってしまったためとの
回答を頂きました。

申し分けありませんが、この件について、ご対応願えないでしょうか。

以下、もう少し詳細に書きます。

[再現方法]
以下のプログラムを、「IP アドレス」に適切な値を入れ、ruby-1.9.2-p0 で実
行する。

 #!/usr/bin/env ruby
 
 require 'net/telnet'
 
 connect = Net::Telnet.new("Host" => "IP アドレス", "Timeout" => 120)
 
 print "closing ..."
 connect.close()
 print "done\n"
 
 # t.rb ends here
 

[結果]
ruby 1.9.2-p0 で行った場合の結果です。

 $ lsb_release -d
 Description:    Debian GNU/Linux unstable (sid)
 $ ruby-192 -v
 ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
 $ ruby-192 /tmp/t.rb
 closing .../tmp/t.rb:8:in `': undefined method `close' for # (NoMethodError)
 

[期待する結果]
ruby 1.8.7 で行った場合の結果です。

 $ ruby -v
 ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]
 $ ruby /tmp/t.rb
 closing ...done
 

[暫定的な解決策]
以下のコードをプログラムに追加する事で、ruby-1.9.2-p0 でも期待する結果
を得られました。

 require 'net/telnet'
 class Net::Telnet
   def method_missing(m, *args, &block)
     @sock.__send__(m, *args, &block)
   end
 end
 

=end


Files

telnet_close_docs.patch.gz (260 Bytes) telnet_close_docs.patch.gz erikh (Erik Hollensbe), 09/16/2010 05:41 AM
telnet_close_method.patch.gz (171 Bytes) telnet_close_method.patch.gz erikh (Erik Hollensbe), 09/16/2010 05:41 AM

Related issues 1 (0 open1 closed)

Related to Backport191 - Backport #3831: ruby 1.9.1-p430 で、Net::Telnet の login が undefined method となり実行できないClosedActions

Updated by erikh (Erik Hollensbe) over 13 years ago

=begin
Included are two patches which may be alternatives to the MM approach above:

  1. Doc patch which clarifies the use of the 'sock' accessor to close the socket.

  2. Simple close method which calls @sock.close.

They are mutually exclusive and support the problem in different ways.

=end

Actions #2

Updated by naruse (Yui NARUSE) over 13 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r29544.
Kiyoto, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0