[ruby-cvs:68336] shyouhei:r61155 (trunk): Add uplevel keyword to Kernel#warn and use it

shyouhei at ruby-lang.org shyouhei at ruby-lang.org
Tue Dec 12 20:56:25 JST 2017


shyouhei	2017-12-12 20:56:25 +0900 (Tue, 12 Dec 2017)

  New Revision: 61155

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61155

  Log:
    Add uplevel keyword to Kernel#warn and use it
    
    If uplevel keyword is given, the warning message is prepended
    with caller file and line information and the string "warning: ".
    The use of the uplevel keyword makes Kernel#warn format output
    similar to how rb_warn formats output.
    
    This patch modifies net/ftp and net/imap to use Kernel#warn
    instead of $stderr.puts or $stderr.printf, since they are used
    for printing warnings.
    
    This makes lib/cgi/core and tempfile use $stderr.puts instead of
    warn for debug logging, since they are used for debug printing
    and not for warning.
    
    This does not modify bundler, rubygems, or rdoc, as those are
    maintained outside of ruby and probably wish to remain backwards
    compatible with older ruby versions.
    
    rb_warn_m code is originally from nobu, but I've changed it
    so that it only includes the path and lineno from uplevel
    (not the method), and also prepends the string "warning: ",
    to make it more similar to rb_warn.
    
    From: Jeremy Evans code at jeremyevans.net
    Signed-off-by: Urabe Shyouhei shyouhei at ruby-lang.org

  Modified files:
    trunk/error.c
    trunk/lib/cgi/core.rb
    trunk/lib/cmath.rb
    trunk/lib/delegate.rb
    trunk/lib/drb/ssl.rb
    trunk/lib/forwardable.rb
    trunk/lib/ipaddr.rb
    trunk/lib/irb/init.rb
    trunk/lib/irb/locale.rb
    trunk/lib/matrix.rb
    trunk/lib/net/ftp.rb
    trunk/lib/net/http/generic_request.rb
    trunk/lib/net/http/header.rb
    trunk/lib/net/http/response.rb
    trunk/lib/net/http.rb
    trunk/lib/net/imap.rb
    trunk/lib/ostruct.rb
    trunk/lib/rexml/cdata.rb
    trunk/lib/rexml/comment.rb
    trunk/lib/rexml/element.rb
    trunk/lib/rexml/instruction.rb
    trunk/lib/rexml/node.rb
    trunk/lib/rexml/text.rb
    trunk/lib/rss/rss.rb
    trunk/lib/tempfile.rb
    trunk/lib/timeout.rb
    trunk/lib/uri/common.rb
    trunk/lib/uri/generic.rb
    trunk/lib/webrick/server.rb
    trunk/lib/webrick/utils.rb
    trunk/lib/yaml.rb
    trunk/test/ruby/test_exception.rb


More information about the ruby-cvs mailing list