Project

General

Profile

Feature #12882 » 0001-Prepend-warning-messages-with-caller-information.patch

jeremyevans0 (Jeremy Evans), 10/28/2016 08:55 PM

View differences:

ext/json/lib/json/ext.rb
module Ext
require 'json/ext/parser'
require 'json/ext/generator'
$DEBUG and warn "Using Ext extension for JSON."
$DEBUG and warn "#{caller(0,1).first}: Using Ext extension for JSON."
JSON.parser = Parser
JSON.generator = Generator
end
ext/openssl/lib/openssl/config.rb
#
# Use #get_value instead
def value(arg1, arg2 = nil) # :nodoc:
warn('Config#value is deprecated; use Config#get_value')
warn("#{caller(1,1).first}: Config#value is deprecated; use Config#get_value")
if arg2.nil?
section, key = 'default', arg1
else
......
#
# Use #[] instead
def section(name) # :nodoc:
warn('Config#section is deprecated; use Config#[]')
warn("#{caller(1,1).first}: Config#section is deprecated; use Config#[]")
@data[name] || {}
end
ext/openssl/lib/openssl/pkey.rb
# :nodoc:
DEFAULT_TMP_DH_CALLBACK = lambda { |ctx, is_export, keylen|
warn "using default DH parameters." if $VERBOSE
warn "#{caller(1,1).first}: using default DH parameters." if $VERBOSE
case keylen
when 1024 then OpenSSL::PKey::DH::DEFAULT_1024
when 2048 then OpenSSL::PKey::DH::DEFAULT_2048
ext/openssl/lib/openssl/x509.rb
class StoreContext
def cleanup
warn "(#{caller.first}) OpenSSL::X509::StoreContext#cleanup is deprecated with no replacement" if $VERBOSE
warn "#{caller(1,1).first}: OpenSSL::X509::StoreContext#cleanup is deprecated with no replacement" if $VERBOSE
end
end
ext/psych/lib/psych/coder.rb
def scalar *args
if args.length > 0
warn "#{caller[0]}: Coder#scalar(a,b,c) is deprecated" if $VERBOSE
warn "#{caller(1,1).first}: Coder#scalar(a,b,c) is deprecated" if $VERBOSE
@tag, @scalar, _ = args
@type = :scalar
end
ext/psych/lib/psych/core_ext.rb
def psych_yaml_as url
return if caller[0].end_with?('rubytypes.rb')
if $VERBOSE
warn "#{caller[0]}: yaml_as is deprecated, please use yaml_tag"
warn "#{caller(1,1).first}: yaml_as is deprecated, please use yaml_tag"
end
Psych.add_tag(url, self)
end
ext/psych/lib/psych/deprecated.rb
end
def self.quick_emit thing, opts = {}, &block # :nodoc:
warn "#{caller[0]}: YAML.quick_emit is deprecated" if $VERBOSE && !caller[0].start_with?(File.dirname(__FILE__))
warn "#{caller(1,1).first}: YAML.quick_emit is deprecated" if $VERBOSE && !caller[0].start_with?(File.dirname(__FILE__))
target = eval 'self', block.binding
target.extend DeprecatedMethods
metaclass = class << target; self; end
......
# This method is deprecated, use Psych.load_stream instead.
def self.load_documents yaml, &block
if $VERBOSE
warn "#{caller[0]}: load_documents is deprecated, use load_stream"
warn "#{caller(1,1).first}: load_documents is deprecated, use load_stream"
end
list = load_stream yaml
return list unless block_given?
......
end
def self.detect_implicit thing
warn "#{caller[0]}: detect_implicit is deprecated" if $VERBOSE
warn "#{caller(1,1).first}: detect_implicit is deprecated" if $VERBOSE
return '' unless String === thing
return 'null' if '' == thing
ss = ScalarScanner.new(ClassLoader.new)
......
end
def self.add_ruby_type type_tag, &block
warn "#{caller[0]}: add_ruby_type is deprecated, use add_domain_type" if $VERBOSE
warn "#{caller(1,1).first}: add_ruby_type is deprecated, use add_domain_type" if $VERBOSE
domain = 'ruby.yaml.org,2002'
key = ['tag', domain, type_tag].join ':'
@domain_types[key] = [key, block]
end
def self.add_private_type type_tag, &block
warn "#{caller[0]}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
warn "#{caller(1,1).first}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
domain = 'x-private'
key = [domain, type_tag].join ':'
@domain_types[key] = [key, block]
end
def self.tagurize thing
warn "#{caller[0]}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
warn "#{caller(1,1).first}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
return thing unless String === thing
"tag:yaml.org,2002:#{thing}"
end
def self.read_type_class type, reference
warn "#{caller[0]}: read_type_class is deprecated" if $VERBOSE
warn "#{caller(1,1).first}: read_type_class is deprecated" if $VERBOSE
_, _, type, name = type.split ':', 4
reference = name.split('::').inject(reference) do |k,n|
......
end
def self.object_maker klass, hash
warn "#{caller[0]}: object_maker is deprecated" if $VERBOSE
warn "#{caller(1,1).first}: object_maker is deprecated" if $VERBOSE
klass.allocate.tap do |obj|
hash.each { |k,v| obj.instance_variable_set(:"@#{k}", v) }
end
ext/psych/lib/psych/visitors/to_ruby.rb
o.init_with c
elsif o.respond_to?(:yaml_initialize)
if $VERBOSE
warn "Implementing #{o.class}#yaml_initialize is deprecated, please implement \"init_with(coder)\""
warn "#{caller(1,1).first}: Implementing #{o.class}#yaml_initialize is deprecated, please implement \"init_with(coder)\""
end
o.yaml_initialize c.tag, c.map
else
ext/psych/lib/psych/visitors/yaml_tree.rb
return super if emitter && ss && options
if $VERBOSE
warn "This API is deprecated, please pass an emitter, scalar scanner, and options or call #{self}.create() (#{caller.first})"
warn "#{caller(1,1).first}: This API is deprecated, please pass an emitter, scalar scanner, and options or call #{self}.create() (#{caller.first})"
end
create emitter, ss
end
......
if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/
unless target.respond_to?(:encode_with)
if $VERBOSE
warn "implementing to_yaml is deprecated, please implement \"encode_with\""
warn "#{caller(1,1).first}: implementing to_yaml is deprecated, please implement \"encode_with\""
end
target.to_yaml(:nodump => true)
ext/win32/lib/Win32API.rb
# frozen_string_literal: true
# for backward compatibility
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead" if $VERBOSE
warn "#{caller(1,1).first.sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead" if $VERBOSE
require 'fiddle/import'
lib/cgi/core.rb
def _header_for_modruby(buf) #:nodoc:
request = Apache::request
buf.scan(/([^:]+): (.+)#{EOL}/o) do |name, value|
warn sprintf("name:%s value:%s\n", name, value) if $DEBUG
warn sprintf("#{caller(0,1).first}: name:%s value:%s\n", name, value) if $DEBUG
case name
when 'Set-Cookie'
request.headers_out.add(name, value)
lib/cmath.rb
atanh
].each do |meth|
define_method(meth + '!') do |*args, &block|
warn("CMath##{meth}! is deprecated; use CMath##{meth} or Math##{meth}") if $VERBOSE
warn("#{caller(1,1).first}: CMath##{meth}! is deprecated; use CMath##{meth} or Math##{meth}") if $VERBOSE
RealMath.send(meth, *args, &block)
end
end
lib/delegate.rb
target = self.__getobj__ {r = false}
r &&= target.respond_to?(m, include_private)
if r && include_private && !target.respond_to?(m, false)
warn "#{caller(3)[0]}: delegator does not forward private method \##{m}"
warn "#{caller(3,1).first}: delegator does not forward private method \##{m}"
return false
end
r
lib/forwardable.rb
method_call = "#{<<-"begin;"}\n#{<<-"end;".chomp}"
begin;
unless ::Kernel.instance_method(:respond_to?).bind(_).call(:"#{method}")
::Kernel.warn "\#{caller_locations(1)[0]}: "#{mesg.dump}"\#{_.class}"'##{method}'
::Kernel.warn "\#{caller_locations(1,1).first}: "#{mesg.dump}"\#{_.class}"'##{method}'
_#{method_call}
else
_.#{method}(*args, &block)
lib/irb/locale.rb
if @encoding_name
begin load 'irb/encoding_aliases.rb'; rescue LoadError; end
if @encoding = @@legacy_encoding_alias_map[@encoding_name]
warn "%s is obsolete. use %s" % ["#{@lang}_#{@territory}.#{@encoding_name}", "#{@lang}_#{@territory}.#{@encoding.name}"]
warn "#{caller(1,1).first}: %s is obsolete. use %s" % ["#{@lang}_#{@territory}.#{@encoding_name}", "#{@lang}_#{@territory}.#{@encoding.name}"]
end
@encoding = Encoding.find(@encoding_name) rescue nil
end
lib/logger.rb
begin
check_shift_log
rescue
warn("log shifting failed. #{$!}")
warn("#{caller(1,1).first}: log shifting failed. #{$!}")
end
end
begin
@dev.write(message)
rescue
warn("log writing failed. #{$!}")
warn("#{caller(1,1).first}: log writing failed. #{$!}")
end
end
rescue Exception => ignored
warn("log writing failed. #{ignored}")
warn("#{caller(1,1).first}: log writing failed. #{ignored}")
end
end
......
rescue Errno::ENOENT
# @filename file would not exist right after #rename and before #create_logfile
if retry_limit <= 0
warn("log rotation inter-process lock failed. #{$!}")
warn("#{caller(1,1).first}: log rotation inter-process lock failed. #{$!}")
else
sleep retry_sleep
retry_limit -= 1
......
end
end
rescue
warn("log rotation inter-process lock failed. #{$!}")
warn("#{caller(1,1).first}: log rotation inter-process lock failed. #{$!}")
end
end
lib/mathn.rb
# class Numeric follows to make this documentation findable in a reasonable
# location
warn('lib/mathn.rb is deprecated') if $VERBOSE
warn("#{caller(0,1).first}: lib/mathn.rb is deprecated") if $VERBOSE
class Numeric; end
lib/matrix.rb
# deprecated; use Matrix#determinant
#
def determinant_e
warn "#{caller(1)[0]}: warning: Matrix#determinant_e is deprecated; use #determinant"
warn "#{caller(1,1).first}: warning: Matrix#determinant_e is deprecated; use #determinant"
determinant
end
alias det_e determinant_e
......
# deprecated; use Matrix#rank
#
def rank_e
warn "#{caller(1)[0]}: warning: Matrix#rank_e is deprecated; use #rank"
warn "#{caller(1,1).first}: warning: Matrix#rank_e is deprecated; use #rank"
rank
end
......
end
def elements_to_f
warn "#{caller(1)[0]}: warning: Matrix#elements_to_f is deprecated, use map(&:to_f)"
warn "#{caller(1,1).first}: warning: Matrix#elements_to_f is deprecated, use map(&:to_f)"
map(&:to_f)
end
def elements_to_i
warn "#{caller(1)[0]}: warning: Matrix#elements_to_i is deprecated, use map(&:to_i)"
warn "#{caller(1,1).first}: warning: Matrix#elements_to_i is deprecated, use map(&:to_i)"
map(&:to_i)
end
def elements_to_r
warn "#{caller(1)[0]}: warning: Matrix#elements_to_r is deprecated, use map(&:to_r)"
warn "#{caller(1,1).first}: warning: Matrix#elements_to_r is deprecated, use map(&:to_r)"
map(&:to_r)
end
......
end
def elements_to_f
warn "#{caller(1)[0]}: warning: Vector#elements_to_f is deprecated"
warn "#{caller(1,1).first}: warning: Vector#elements_to_f is deprecated"
map(&:to_f)
end
def elements_to_i
warn "#{caller(1)[0]}: warning: Vector#elements_to_i is deprecated"
warn "#{caller(1,1).first}: warning: Vector#elements_to_i is deprecated"
map(&:to_i)
end
def elements_to_r
warn "#{caller(1)[0]}: warning: Vector#elements_to_r is deprecated"
warn "#{caller(1,1).first}: warning: Vector#elements_to_r is deprecated"
map(&:to_r)
end
lib/net/http.rb
# http.start { .... }
#
def set_debug_output(output)
warn 'Net::HTTP#set_debug_output called after HTTP started' if started?
warn "#{caller(1,1).first}: Net::HTTP#set_debug_output called after HTTP started" if started?
@debug_output = output
end
lib/net/http/generic_request.rb
end
def body_exist?
warn "Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE
warn "#{caller(1,1).first}: Net::HTTPRequest#body_exist? is obsolete; use response_body_permitted?" if $VERBOSE
response_body_permitted?
end
......
def supply_default_content_type
return if content_type()
warn 'net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded' if $VERBOSE
warn "#{caller(1,1).first}: net/http: warning: Content-Type did not set; using application/x-www-form-urlencoded" if $VERBOSE
set_content_type 'application/x-www-form-urlencoded'
end
lib/net/http/header.rb
@header = {}
return unless initheader
initheader.each do |key, value|
warn "net/http: warning: duplicated HTTP header: #{key}" if key?(key) and $VERBOSE
warn "#{caller(1,1).first}: net/http: warning: duplicated HTTP header: #{key}" if key?(key) and $VERBOSE
if value.nil?
warn "net/http: warning: nil HTTP header: #{key}" if $VERBOSE
warn "#{caller(1,1).first}: net/http: warning: nil HTTP header: #{key}" if $VERBOSE
else
@header[key.downcase] = [value.strip]
end
lib/net/http/response.rb
#
def response #:nodoc:
warn "#{caller(1)[0]}: warning: Net::HTTPResponse#response is obsolete" if $VERBOSE
warn "#{caller(1,1).first}: warning: Net::HTTPResponse#response is obsolete" if $VERBOSE
self
end
def header #:nodoc:
warn "#{caller(1)[0]}: warning: Net::HTTPResponse#header is obsolete" if $VERBOSE
warn "#{caller(1,1).first}: warning: Net::HTTPResponse#header is obsolete" if $VERBOSE
self
end
def read_header #:nodoc:
warn "#{caller(1)[0]}: warning: Net::HTTPResponse#read_header is obsolete" if $VERBOSE
warn "#{caller(1,1).first}: warning: Net::HTTPResponse#read_header is obsolete" if $VERBOSE
self
end
lib/rexml/cdata.rb
# c = CData.new( " Some text " )
# c.write( $stdout ) #-> <![CDATA[ Some text ]]>
def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
Kernel.warn( "#{self.class.name}.write is deprecated" )
Kernel.warn( "#{caller(1,1).first}: #{self.class.name}.write is deprecated" )
indent( output, indent )
output << START
output << @string
lib/rexml/comment.rb
# ie_hack::
# Needed for conformity to the child API, but not used by this class.
def write( output, indent=-1, transitive=false, ie_hack=false )
Kernel.warn("Comment.write is deprecated. See REXML::Formatters")
Kernel.warn("#{caller(1,1).first}: Comment.write is deprecated. See REXML::Formatters")
indent( output, indent )
output << START
output << @string
lib/rexml/element.rb
# doc.write( out ) #-> doc is written to the string 'out'
# doc.write( $stdout ) #-> doc written to the console
def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)
Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters")
Kernel.warn("#{caller(1,1).first}: #{self.class.name}.write is deprecated. See REXML::Formatters")
formatter = if indent > -1
if transitive
require "rexml/formatters/transitive"
lib/rexml/instruction.rb
# See the rexml/formatters package
#
def write writer, indent=-1, transitive=false, ie_hack=false
Kernel.warn( "#{self.class.name}.write is deprecated" )
Kernel.warn( "#{caller(1,1).first}: #{self.class.name}.write is deprecated" )
indent(writer, indent)
writer << START.sub(/\\/u, '')
writer << @target
lib/rexml/node.rb
# REXML::Formatters package for changing the output style.
def to_s indent=nil
unless indent.nil?
Kernel.warn( "#{self.class.name}.to_s(indent) parameter is deprecated" )
Kernel.warn( "#{caller(1,1).first}: #{self.class.name}.to_s(indent) parameter is deprecated" )
f = REXML::Formatters::Pretty.new( indent )
f.write( self, rv = "" )
else
lib/rexml/text.rb
# See REXML::Formatters
#
def write( writer, indent=-1, transitive=false, ie_hack=false )
Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters")
Kernel.warn("#{caller(1,1).first}: #{self.class.name}.write is deprecated. See REXML::Formatters")
formatter = if indent > -1
REXML::Formatters::Pretty.new( indent )
else
lib/rss/rss.rb
def #{accessor_name}=(*args)
receiver = self.class.name
warn("Warning:\#{caller.first.sub(/:in `.*'\z/, '')}: " \
warn("Warning:\#{caller(1,1).first.sub(/:in `.*'\z/, '')}: " \
"Don't use `\#{receiver}\##{accessor_name} = XXX'/" \
"`\#{receiver}\#set_#{accessor_name}(XXX)'. " \
"Those APIs are not sense of Ruby. " \
lib/tempfile.rb
# If Tempfile.new cannot find a unique filename within a limited
# number of tries, then it will raise an exception.
def initialize(basename="", tmpdir=nil, mode: 0, **options)
warn "Tempfile.new doesn't call the given block." if block_given?
warn "#{caller(1,1).first}: Tempfile.new doesn't call the given block." if block_given?
@unlinked = false
@mode = mode|File::RDWR|File::CREAT|File::EXCL
......
def call(*args)
return if @pid != Process.pid
warn "removing #{@tmpfile.path}..." if $DEBUG
warn "#{caller(1,1).first}: removing #{@tmpfile.path}..." if $DEBUG
@tmpfile.close unless @tmpfile.closed?
begin
......
rescue Errno::ENOENT
end
warn "done" if $DEBUG
warn "#{caller(1,1).first}: done" if $DEBUG
end
end
lib/uri/common.rb
# # => "@%3F@%21"
#
def escape(*arg)
warn "#{caller(1)[0]}: warning: URI.escape is obsolete" if $VERBOSE
warn "#{caller(1,1).first}: warning: URI.escape is obsolete" if $VERBOSE
DEFAULT_PARSER.escape(*arg)
end
alias encode escape
......
# # => "http://example.com/?a=\t\r"
#
def unescape(*arg)
warn "#{caller(1)[0]}: warning: URI.unescape is obsolete" if $VERBOSE
warn "#{caller(1,1).first}: warning: URI.unescape is obsolete" if $VERBOSE
DEFAULT_PARSER.unescape(*arg)
end
alias decode unescape
......
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
#
def self.extract(str, schemes = nil, &block)
warn "#{caller(1)[0]}: warning: URI.extract is obsolete" if $VERBOSE
warn "#{caller(1,1).first}: warning: URI.extract is obsolete" if $VERBOSE
DEFAULT_PARSER.extract(str, schemes, &block)
end
......
# end
#
def self.regexp(schemes = nil)
warn "#{caller(1)[0]}: warning: URI.regexp is obsolete" if $VERBOSE
warn "#{caller(1,1).first}: warning: URI.regexp is obsolete" if $VERBOSE
DEFAULT_PARSER.make_regexp(schemes)
end
lib/uri/generic.rb
elsif name == 'http_proxy'
unless proxy_uri = env[name]
if proxy_uri = env[name.upcase]
warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.'
warn "#{caller(1,1).first}: The environment variable HTTP_PROXY is discouraged. Use http_proxy."
end
end
else
lib/webrick/utils.rb
Process::Sys::setgid(pw.gid)
Process::Sys::setuid(pw.uid)
else
warn("WEBrick::Utils::su doesn't work on this platform")
warn("#{caller(1,1).first}: WEBrick::Utils::su doesn't work on this platform")
end
end
module_function :su
lib/yaml.rb
begin
require 'psych'
rescue LoadError
warn "#{caller[0]}:"
warn "It seems your ruby installation is missing psych (for YAML output)."
warn "To eliminate this warning, please install libyaml and reinstall your ruby."
warn <<-eowarn
#{caller(1,1).first}
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
eowarn
raise
end
test/logger/test_logdevice.rb
logdev.close
$stderr, stderr = stderr, $stderr
end
assert_equal "log writing failed. disk is full\n", stderr
assert_include stderr, "log writing failed. disk is full\n"
end
def test_close
(1-1/2)