ruby/ruby — pull request #509 by ArtemPyanykh (2014-01-20 15:28:03+00:00)
Title: Fix bug when URI::Generic#to_s fails for allocated objects.

When initialized URI::Generic always have non-nil @path. But when object
is just allocated, @path == nil, and #path_query returns nil.
With that in mind we can see, that #to_s will fail on line 1484
str << path_query
with 'TypeError: no implicit conversion of nil into String'.

In normal circumstances we will always have initialized URI::Generic's,
and that problem won't affect us.

However, it will affect us during debugging. If we step into
URI::Generic.new(...), context will switch to allocated URI::Generic
with @path == nil. Most common debuggers have prompt with current
context. For example in 'pry_debugger' it looks like this
2.0.0 (#):0 >

As you can see, if we step into initialization of new URI::Generic,
debugger will crash due to above mentioned TypeError.

I believe it is not a debugger problem, since having current context in
prompt is very convenient, but a slight defect in a library code.