Skip to content

Commit

Permalink
Thread::Backtrace::Location#path is an alias.
Browse files Browse the repository at this point in the history
Per Nobu (https://bugs.ruby-lang.org/issues/10561#note-4) the "path" method
should be an alias to "absolute_path" instead of only returning the basename.
I'll set up a patch to correct the documentation of MRI regarding this method.
  • Loading branch information
Yorick Peterse committed Feb 4, 2015
1 parent 5120a6a commit 217034f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
12 changes: 1 addition & 11 deletions kernel/common/thread.rb
Expand Up @@ -150,17 +150,7 @@ def initialize(label, absolute_path, lineno)
end

alias_method :base_label, :label

##
# The MRI documentation states this method should return the file name. In
# reality however this method just returns the full path.
#
# Rubinius here sticks to whatever the documentation specifies, thus we
# return only the filename.
#
def path
File.basename(absolute_path)
end
alias_method :path, :absolute_path

def to_s
"#{absolute_path}:#{lineno}:in `#{label}'"
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/core/thread/backtrace/location/path_spec.rb
Expand Up @@ -6,7 +6,7 @@
@frame = ThreadBacktraceLocationSpecs.locations[0]
end

it 'returns the file name of the call frame' do
@frame.path.should == File.basename(__FILE__)
it 'returns the absolute path of the call frame' do
@frame.path.should == __FILE__
end
end

0 comments on commit 217034f

Please sign in to comment.