[#24105] [Bug #1711] Marshal Failing to Round-Trip Certain Recurisve Data Structures — Run Paint Run Run <redmine@...>

Bug #1711: Marshal Failing to Round-Trip Certain Recurisve Data Structures

9 messages 2009/07/01

[#24116] [Bug #1715] Numeric#arg for NaN is Inconsistent Across Versions — Run Paint Run Run <redmine@...>

Bug #1715: Numeric#arg for NaN is Inconsistent Across Versions

10 messages 2009/07/02

[#24240] [Bug #1755] IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8 — Run Paint Run Run <redmine@...>

Bug #1755: IO#reopen Doesn't Fully Associate with Given Stream on 1.9; Ignores pos on 1.8

8 messages 2009/07/09

[#24321] [Bug #1773] Gem path doesn't honor user gem? — Lin Jen-Shin <redmine@...>

Bug #1773: Gem path doesn't honor user gem?

12 messages 2009/07/14

[#24390] [Feature #1784] More encoding (Big5 series) support? — Lin Jen-Shin <redmine@...>

Feature #1784: More encoding (Big5 series) support?

12 messages 2009/07/16

[#24467] Re: [ruby-cvs:31226] Ruby:r24008 (ruby_1_8_6): Removed private on to_date and to_datetime. — Urabe Shyouhei <shyouhei@...>

Hello.

10 messages 2009/07/21

[#24472] [Feature #1800] rubygems can replace system executable files — Kazuhiro NISHIYAMA <redmine@...>

Feature #1800: rubygems can replace system executable files

13 messages 2009/07/21

[#24530] [Feature #1811] Default BasicSocket.do_not_reverse_lookup to true — Roger Pack <redmine@...>

Feature #1811: Default BasicSocket.do_not_reverse_lookup to true

9 messages 2009/07/23

[#24624] [Bug #1844] Immediates Should Not Respond to :dup — Run Paint Run Run <redmine@...>

Bug #1844: Immediates Should Not Respond to :dup

15 messages 2009/07/30

[ruby-core:24645] [Bug #1850] Net::FTP#login missing precondition. Little descriptive exception raised when given nil password together with a username different of anonymous

From: Miguel Fernández <redmine@...>
Date: 2009-07-31 11:49:58 UTC
List: ruby-core #24645
Bug #1850: Net::FTP#login missing precondition. Little descriptive exception raised when given nil password together with a username different of anonymous
http://redmine.ruby-lang.org/issues/show/1850

Author: Miguel Fern叩ndez
Status: Open, Priority: Low
ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

When Net::FTP#login is invoked giving a not nil password, and a user different from "anonymous" the following error is raised: TypeError.new("can't convert nil into String") 

This happens due to the fact that in lib/net/ftp.rb (line 381) password is concatenated with a string, without cheking first if it is nil.

The error can be reproduced this way:

[1] Simple (wrong) use of Net::FTP#login
========================================

ftp=Net::FTP.new "petra.euitio.uniovi.es"
ftp.login "i1650878"

Error stack trace
=================
TypeError: can't convert nil into String
        from /usr/lib/ruby/1.8/net/ftp.rb:381:in `+'
        from /usr/lib/ruby/1.8/net/ftp.rb:381:in `login'
        from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from /usr/lib/ruby/1.8/net/ftp.rb:378:in `login'
        from (irb):7
        from :0

Although the error is somehow easy to discover its meaning is not directly related with the use of Net::FTP#login method. What's more, if Net::FTP#login is used from a higher level API, it's quite difficult to figure out what's happening without getting deep into the code (See[2]). In my humble opinion, it shouldn't be Net::FTP users' concern if nil can't be concateneted with a String. I think this should be a contract that the own method has to provide by means of a precondition. 


[2] - Not so wrong use of Net::FTP#login from Kernel#open in lib/open-uri.rb:
============================================================================
require 'open-uri'
open('ftp://i1891823@petra.euitio.uniovi.es/home/alumnos/i1891823/csv.txt')


Error stack trace
=================
TypeError: can't convert nil into String
        from /usr/lib/ruby/1.8/net/ftp.rb:381:in `+'
        from /usr/lib/ruby/1.8/net/ftp.rb:381:in `login'
        from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from /usr/lib/ruby/1.8/net/ftp.rb:378:in `login'
        from /usr/lib/ruby/1.8/open-uri.rb:657:in `buffer_open'
        from /usr/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
        from /usr/lib/ruby/1.8/open-uri.rb:162:in `catch'
        from /usr/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
        from /usr/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
        from /usr/lib/ruby/1.8/open-uri.rb:518:in `open'
        from /usr/lib/ruby/1.8/open-uri.rb:30:in `open'
        from (irb):14


----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next