From: merch-redmine@... Date: 2020-09-23T23:03:17+00:00 Subject: [ruby-core:100094] [Ruby master Feature#10561] Improve function of Thread::Backtrace::Location #path and #absolute_path Issue #10561 has been updated by jeremyevans0 (Jeremy Evans). Backport deleted (2.0.0: UNKNOWN, 2.1: UNKNOWN) ruby -v deleted (2.2.0) Tracker changed from Bug to Feature I've improved the documentation for `#path` and `#absolute path` in commit:fae135c5b39db173bf97dfa3c3a34eb8fb230276. The current behavior is not a bug, so switching this to a feature request. Personally, I'm OK with suggestions 1, 2, and 4 and willing to implement the changes if they are desired. I don't think adding `#filename` (suggestion 3) is worth it. It doesn't seem to be needed in most code, and `File.basename` can be used in the cases where it is needed (and people that need it can define the method themselves). ---------------------------------------- Feature #10561: Improve function of Thread::Backtrace::Location #path and #absolute_path https://bugs.ruby-lang.org/issues/10561#change-87663 * Author: sam.saffron (Sam Saffron) * Status: Open * Priority: Normal ---------------------------------------- I was working on this issue in Rails and hit an area where Backtrace Location can be improved https://github.com/rails/rails/pull/17782 1. It is undefined in the documentation how #absolute_path should operate when #path is invalid (in case of instance eval) 2. There are a few conditions where #path and #absolute_path can return nil, this forces extra protection code when parsing paths to check for nil. (for example getting filename) Suggestions: 1. Instead of returning Qnil from location_path and location_absolute_path on invalid conditions, return the string "(unknown)" which is easier to parse and sticks out better in a big backtrace. There is precedent here with the string "(eval)" 2. If path is invalid have absolute_path return "(unknown)", define that in the documentation 3. (possible) add an additional method on caller_location called #filename so people stop parsing filename from #path and #absolute_path 4. Evaluate if it makes sense to have #path and #absolute_path in the API as both methods can return full paths so the semantic difference is subtle. -- https://bugs.ruby-lang.org/ Unsubscribe: