diff options
author | Jeremy Evans <code@jeremyevans.net> | 2020-07-24 08:09:50 -0700 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-07-31 21:07:19 +0900 |
commit | 1a935606b5e307375ce9d4215a46da2ca91dc1d6 (patch) | |
tree | 902d7cdddb5650724d56c9a4f2ad9108cbc3a576 /lib/rubygems | |
parent | 331fe6a88f96d9f986da55e003e896c2bc181db0 (diff) | |
download | ruby-1a935606b5e307375ce9d4215a46da2ca91dc1d6.tar.gz |
[rubygems/rubygems] Fix Kernel#warn override to handle backtrace location with nil path
It's very unlikely to hit this case, but it is possible, as
Thread::Backtrace::Location#path can return nil if the location is
a cfunc with no previous iseq. See location_path in vm_backtrace.c
in Ruby.
https://github.com/rubygems/rubygems/commit/511935645a
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/core_ext/kernel_warn.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/rubygems/core_ext/kernel_warn.rb b/lib/rubygems/core_ext/kernel_warn.rb index e10a845b98..e030ef815c 100644 --- a/lib/rubygems/core_ext/kernel_warn.rb +++ b/lib/rubygems/core_ext/kernel_warn.rb @@ -38,10 +38,11 @@ if RUBY_VERSION >= "2.5" start += 1 - path = loc.path - unless path.start_with?(rubygems_path) or path.start_with?('<internal:') - # Non-rubygems frames - uplevel -= 1 + if path = loc.path + unless path.start_with?(rubygems_path) or path.start_with?('<internal:') + # Non-rubygems frames + uplevel -= 1 + end end end uplevel = start |