From 656a943110572c0fc8d09861995238119376b875 Mon Sep 17 00:00:00 2001 From: nick evans Date: Tue, 3 Feb 2026 15:05:17 -0500 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Don't=20hardcode=20parser?= =?UTF-8?q?=20deprecation=20warning=20uplevel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This finds the first non-parser entry in the call stack to determine the deprecation warning's `uplevel`. --- lib/net/imap/response_parser.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/net/imap/response_parser.rb b/lib/net/imap/response_parser.rb index 189bc980..823ff0df 100644 --- a/lib/net/imap/response_parser.rb +++ b/lib/net/imap/response_parser.rb @@ -2022,13 +2022,18 @@ def resp_code_copy__data CopyUID(validity, src_uids, dst_uids) end + PARSER_PATH = File.expand_path(__FILE__).delete_suffix(".rb") + # TODO: remove this code in the v0.6.0 release def DeprecatedUIDPlus(validity, src_uids = nil, dst_uids) return unless config.parser_use_deprecated_uidplus_data + uplevel = caller_locations + .find_index { !_1.path.start_with?(PARSER_PATH) } + &.succ warn("#{Config}#parser_use_deprecated_uidplus_data is ignored " \ "since v0.6.0. Disable this warning by setting " \ "config.parser_use_deprecated_uidplus_data = false.", - category: :deprecated, uplevel: 9) + category: :deprecated, uplevel:) nil end