Bug #9063 ยป irb-when-backtrace-nil.patch
lib/irb.rb | ||
---|---|---|
end
|
||
if exc
|
||
print exc.class, ": ", exc, "\n"
|
||
if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
|
||
if exc.backtrace && exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
|
||
!(SyntaxError === exc)
|
||
irb_bug = true
|
||
else
|
||
... | ... | |
messages = []
|
||
lasts = []
|
||
levels = 0
|
||
for m in exc.backtrace
|
||
m = @context.workspace.filter_backtrace(m) unless irb_bug
|
||
if m
|
||
if messages.size < @context.back_trace_limit
|
||
messages.push "\tfrom "+m
|
||
else
|
||
lasts.push "\tfrom "+m
|
||
if lasts.size > @context.back_trace_limit
|
||
lasts.shift
|
||
levels += 1
|
||
if exc.backtrace
|
||
for m in exc.backtrace
|
||
m = @context.workspace.filter_backtrace(m) unless irb_bug
|
||
if m
|
||
if messages.size < @context.back_trace_limit
|
||
messages.push "\tfrom "+m
|
||
else
|
||
lasts.push "\tfrom "+m
|
||
if lasts.size > @context.back_trace_limit
|
||
lasts.shift
|
||
levels += 1
|
||
end
|
||
end
|
||
end
|
||
end
|
||
-
|
test/irb/test_raise_no_backtrace_exception.rb | ||
---|---|---|
require 'test/unit'
|
||
require_relative '../ruby/envutil'
|
||
module TestIRB
|
||
class TestRaiseNoBacktraceException < Test::Unit::TestCase
|
||
def test_raise_exception
|
||
status = assert_in_out_err(%w[-rirb -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
|
||
e = Exception.new("foo")
|
||
def e.backtrace; nil; end
|
||
raise e
|
||
IRB
|
||
end
|
||
end
|
||
end
|