* lib/irb.rb: Prevent irb from crashing when exception with
nil backtrace is raised. [fix GH-434][ruby-core:58078][Bug #9063] * test/irb/test_raise_no_backtrace_exception.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
087d1d2749
commit
f741fd2d9d
@ -1,3 +1,10 @@
|
|||||||
|
Wed Aug 13 11:17:00 2014 Shimpei Makimoto <github@makimoto.org>
|
||||||
|
|
||||||
|
* lib/irb.rb: Prevent irb from crashing when exception with
|
||||||
|
nil backtrace is raised.
|
||||||
|
[fix GH-434][ruby-core:58078][Bug #9063]
|
||||||
|
* test/irb/test_raise_no_backtrace_exception.rb: ditto.
|
||||||
|
|
||||||
Wed Aug 13 11:08:55 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
Wed Aug 13 11:08:55 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||||
|
|
||||||
* lib/irb/completion.rb: fixed broken completion list with
|
* lib/irb/completion.rb: fixed broken completion list with
|
||||||
|
24
lib/irb.rb
24
lib/irb.rb
@ -497,7 +497,7 @@ module IRB
|
|||||||
end
|
end
|
||||||
if exc
|
if exc
|
||||||
print exc.class, ": ", exc, "\n"
|
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)
|
!(SyntaxError === exc)
|
||||||
irb_bug = true
|
irb_bug = true
|
||||||
else
|
else
|
||||||
@ -507,16 +507,18 @@ module IRB
|
|||||||
messages = []
|
messages = []
|
||||||
lasts = []
|
lasts = []
|
||||||
levels = 0
|
levels = 0
|
||||||
for m in exc.backtrace
|
if exc.backtrace
|
||||||
m = @context.workspace.filter_backtrace(m) unless irb_bug
|
for m in exc.backtrace
|
||||||
if m
|
m = @context.workspace.filter_backtrace(m) unless irb_bug
|
||||||
if messages.size < @context.back_trace_limit
|
if m
|
||||||
messages.push "\tfrom "+m
|
if messages.size < @context.back_trace_limit
|
||||||
else
|
messages.push "\tfrom "+m
|
||||||
lasts.push "\tfrom "+m
|
else
|
||||||
if lasts.size > @context.back_trace_limit
|
lasts.push "\tfrom "+m
|
||||||
lasts.shift
|
if lasts.size > @context.back_trace_limit
|
||||||
levels += 1
|
lasts.shift
|
||||||
|
levels += 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
14
test/irb/test_raise_no_backtrace_exception.rb
Normal file
14
test/irb/test_raise_no_backtrace_exception.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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
|
Loading…
x
Reference in New Issue
Block a user