summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2021-06-24 08:20:20 -0700
committerGitHub <noreply@github.com>2021-06-24 08:20:20 -0700
commitc9a2b9f3803fae764c7339058c7a9c88adbd692e (patch)
tree4eacdb31f81345ce28e8ecd0edbf928e52ecfdd3
parent2205419ad84a18881fc57fdb2ec3fe492228dcea (diff)
parentb55435a2cce89dafd915b95310eb8b300afd5aaa (diff)
downloadchef-c9a2b9f3803fae764c7339058c7a9c88adbd692e.tar.gz
Merge pull request #11749 from chef/lcg/fix-deprecation-edge-case
-rw-r--r--lib/chef/deprecated.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/chef/deprecated.rb b/lib/chef/deprecated.rb
index ae205497c4..4960e03871 100644
--- a/lib/chef/deprecated.rb
+++ b/lib/chef/deprecated.rb
@@ -79,10 +79,12 @@ class Chef
return true if location =~ /^(.*?):(\d+):in/ && begin
# Don't buffer the whole file in memory, so read it one line at a time.
line_no = $2.to_i
- location_file = ::File.open($1)
- (line_no - 1).times { location_file.readline } # Read all the lines we don't care about.
- relevant_line = location_file.readline
- relevant_line.match?(/#.*chef:silence_deprecation($|[^:]|:#{self.class.deprecation_key})/)
+ if File.exist?($1) # some stacktraces come from `eval` and not a file
+ location_file = ::File.open($1)
+ (line_no - 1).times { location_file.readline } # Read all the lines we don't care about.
+ relevant_line = location_file.readline
+ relevant_line.match?(/#.*chef:silence_deprecation($|[^:]|:#{self.class.deprecation_key})/)
+ end
end
false