mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00

[Bug #19350] * Merge RubyGems-3.4.2 and Bundler-2.4.2 * Merge RubyGems-3.4.3 and Bundler-2.4.3 * Generate parser-text.rb of racc when sync it * Ignore LICENSE files of libraries vendored in rubygems [ci skip] * Adjust spec of bundler like as `sync_default_gems` [ci skip] * Fixed a typo * Removed vendored LICENSE file. * Update LEGAL sections for pub_grub * Merge RubyGems-3.4.4 and Bundler-2.4.4 * Merge RubyGems-3.4.5 and Bundler-2.4.5 Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
50 lines
1.1 KiB
Ruby
50 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Kernel
|
|
rubygems_path = "#{__dir__}/" # Frames to be skipped start with this path.
|
|
|
|
original_warn = instance_method(:warn)
|
|
|
|
remove_method :warn
|
|
|
|
class << self
|
|
remove_method :warn
|
|
end
|
|
|
|
module_function define_method(:warn) {|*messages, **kw|
|
|
unless uplevel = kw[:uplevel]
|
|
if Gem.java_platform? && RUBY_VERSION < "3.1"
|
|
return original_warn.bind(self).call(*messages)
|
|
else
|
|
return original_warn.bind(self).call(*messages, **kw)
|
|
end
|
|
end
|
|
|
|
# Ensure `uplevel` fits a `long`
|
|
uplevel, = [uplevel].pack("l!").unpack("l!")
|
|
|
|
if uplevel >= 0
|
|
start = 0
|
|
while uplevel >= 0
|
|
loc, = caller_locations(start, 1)
|
|
unless loc
|
|
# No more backtrace
|
|
start += uplevel
|
|
break
|
|
end
|
|
|
|
start += 1
|
|
|
|
if path = loc.path
|
|
unless path.start_with?(rubygems_path) || path.start_with?("<internal:")
|
|
# Non-rubygems frames
|
|
uplevel -= 1
|
|
end
|
|
end
|
|
end
|
|
kw[:uplevel] = start
|
|
end
|
|
|
|
original_warn.bind(self).call(*messages, **kw)
|
|
}
|
|
end
|