Skip to content

Made Exception#set_backtrace compliant with Ruby documentation#2068

Merged
headius merged 2 commits intojruby:jruby-1_7from
pabloatplumbee:jruby-1_7
Nov 2, 2014
Merged

Made Exception#set_backtrace compliant with Ruby documentation#2068
headius merged 2 commits intojruby:jruby-1_7from
pabloatplumbee:jruby-1_7

Conversation

@pabloatplumbee
Copy link
Contributor

This change fixes #1919, and makes jRuby complaint with Exception#set_backtrace documentation, which states that:

The backtrace must be an array of String objects or a single String in the format described in #backtrace.

This behaviour is confirmed in different MRI versions:

ruby-1.9.3-p545

1.9.3-p545 :001 > Exception.new.set_backtrace 'foo'
 => ["foo"] 
1.9.3-p545 :002 > 

ruby-2.0.0-p0

irb(main):001:0>  Exception.new.set_backtrace 'foo'
=> ["foo"]

ruby-2.1.1

2.1.1 :001 > Exception.new.set_backtrace 'foo'
 => ["foo"] 

But not in jruby:

jruby-1.7.11

jruby-1.7.11 :001 >  Exception.new.set_backtrace 'foo'
TypeError: backtrace must be Array of String
    from org/jruby/RubyException.java:95:in `set_backtrace'
    from (irb):1:in `evaluate'
    from org/jruby/RubyKernel.java:1121:in `eval'
    from org/jruby/RubyKernel.java:1521:in `loop'
    from org/jruby/RubyKernel.java:1284:in `catch'
    from org/jruby/RubyKernel.java:1284:in `catch'
    from /home/pablo/.rvm/rubies/jruby-1.7.11/bin/irb:13:in `(root)'

jruby-1.7.13

jruby-1.7.13 :001 >  Exception.new.set_backtrace 'foo'
TypeError: backtrace must be Array of String
    from org/jruby/RubyException.java:95:in `set_backtrace'
    from (irb):1:in `evaluate'
    from org/jruby/RubyKernel.java:1101:in `eval'
    from org/jruby/RubyKernel.java:1501:in `loop'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from org/jruby/RubyKernel.java:1264:in `catch'
    from /home/pablo/.rvm/rubies/jruby-1.7.13/bin/irb:13:in `(root)'

@headius
Copy link
Member

headius commented Nov 2, 2014

Looks good...is there a test for this somewhere? If not, you can add to our regression suite (spec/regression) or to MRI or RubySpec. We use them all.

headius added a commit that referenced this pull request Nov 2, 2014
Made Exception#set_backtrace compliant with Ruby documentation
@headius headius merged commit ceb199a into jruby:jruby-1_7 Nov 2, 2014
@headius
Copy link
Member

headius commented Nov 2, 2014

Wow, ok, I totally missed that the second file modified was a test. No worries, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants