Skip to content

Commit fa23f0f

Browse files
authored
Merge pull request rails#51619 from Earlopain/ruby-3.4-backtraces
Filter internal frames in deprecation warnings for Ruby 3.4
2 parents 2bb6782 + c85eca4 commit fa23f0f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

activesupport/lib/active_support/deprecation/reporting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _extract_callstack(callstack)
172172
LIB_DIR = RbConfig::CONFIG["libdir"]
173173

174174
def ignored_callstack?(path)
175-
path.start_with?(RAILS_GEM_ROOT, LIB_DIR)
175+
path.start_with?(RAILS_GEM_ROOT, LIB_DIR) || path.include?("<internal:")
176176
end
177177
end
178178
end

activesupport/test/deprecation_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,11 +975,22 @@ def generated_method_that_call_deprecation(deprecator)
975975
end
976976
end
977977

978+
test "warn deprecation can blame code from internal methods" do
979+
@deprecator.behavior = ->(message, *) { @message = message }
980+
method_that_emits_deprecation_with_internal_method(@deprecator)
981+
982+
assert_not_includes(@message, "internal")
983+
end
984+
978985
private
979986
def method_that_emits_deprecation(deprecator)
980987
deprecator.warn
981988
end
982989

990+
def method_that_emits_deprecation_with_internal_method(deprecator)
991+
[1].each { deprecator.warn }
992+
end
993+
983994
def with_rails_application_deprecators(&block)
984995
application = Struct.new(:deprecators).new(ActiveSupport::Deprecation::Deprecators.new)
985996
rails = Struct.new(:application).new(application)

0 commit comments

Comments
 (0)