Project

General

Profile

irb-when-backtrace-nil.patch

makimoto (Shimpei Makimoto), 10/31/2013 07:27 AM

View differences:

lib/irb.rb
499 499
          end
500 500
          if exc
501 501
            print exc.class, ": ", exc, "\n"
502
            if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
502
            if exc.backtrace && exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
503 503
                !(SyntaxError === exc)
504 504
              irb_bug = true
505 505
            else
......
509 509
            messages = []
510 510
            lasts = []
511 511
            levels = 0
512
            for m in exc.backtrace
513
              m = @context.workspace.filter_backtrace(m) unless irb_bug
514
              if m
515
                if messages.size < @context.back_trace_limit
516
                  messages.push "\tfrom "+m
517
                else
518
                  lasts.push "\tfrom "+m
519
                  if lasts.size > @context.back_trace_limit
520
                    lasts.shift
521
                    levels += 1
512
            if exc.backtrace
513
              for m in exc.backtrace
514
                m = @context.workspace.filter_backtrace(m) unless irb_bug
515
                if m
516
                  if messages.size < @context.back_trace_limit
517
                    messages.push "\tfrom "+m
518
                  else
519
                    lasts.push "\tfrom "+m
520
                    if lasts.size > @context.back_trace_limit
521
                      lasts.shift
522
                      levels += 1
523
                    end
522 524
                  end
523 525
                end
524 526
              end
525
- 
test/irb/test_raise_no_backtrace_exception.rb
1
require 'test/unit'
2
require_relative '../ruby/envutil'
3

  
4
module TestIRB
5
  class TestRaiseNoBacktraceException < Test::Unit::TestCase
6
    def test_raise_exception
7
      status = assert_in_out_err(%w[-rirb -e IRB.start(__FILE__) -- -f --], <<-IRB, /Exception: foo/, [])
8
      e = Exception.new("foo")
9
      def e.backtrace; nil; end
10
      raise e
11
IRB
12
    end
13
  end
14
end
0
-