commit:     688623645b5e0a3b2b20244535e564934f0e98ee
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sat Nov 29 22:38:27 2025 +0000
Commit:     Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Sat Nov 29 22:38:27 2025 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=68862364

chore: suppress framedepth issues from the compatibility shim for deprecation

Signed-off-by: Brian Harring <ferringb <AT> gmail.com>

 src/snakeoil/demandload.py  | 6 ++----
 src/snakeoil/deprecation.py | 8 ++++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/snakeoil/demandload.py b/src/snakeoil/demandload.py
index 400200a..4317add 100644
--- a/src/snakeoil/demandload.py
+++ b/src/snakeoil/demandload.py
@@ -1,11 +1,10 @@
 __all__ = ("demand_compile_regexp",)
 
-import re
 import sys
 import typing
 
 from .delayed import regexp
-from .deprecation import deprecated
+from .deprecation import deprecated, deprecation_frame_depth
 
 
 @deprecated("snakeoil.klass.demand_compile_regexp has moved to 
snakeoil.delayed.regexp")
@@ -17,7 +16,6 @@ def demand_compile_regexp(
     The mechanism of injecting into the scope is deprecated; move to 
snakeoil.delayed.regexp.
     """
     if scope is None:
-        # Note 2, not 1- we're wrapped in deprecated so we *are* two levels in.
-        scope = sys._getframe(2).f_globals
+        scope = sys._getframe(deprecation_frame_depth).f_globals
     delayed = regexp(pattern, flags)
     scope[name] = delayed

diff --git a/src/snakeoil/deprecation.py b/src/snakeoil/deprecation.py
index e0b85a9..8cd3730 100644
--- a/src/snakeoil/deprecation.py
+++ b/src/snakeoil/deprecation.py
@@ -4,12 +4,16 @@ import warnings
 from contextlib import contextmanager
 
 _import_failed = False
+deprecation_frame_depth = 1  # some old code does "reach up the stack" tricks. 
 Thus it has to know how far up to climb.
 try:
-    from warnings import deprecated  # pyright: ignore[reportAssignmentType]
+    from warnings import deprecated  # pyright: 
ignore[reportAttributeAccessIssue]
+
+    deprecation_frame_depth = 2
 except ImportError:
     _import_failed = True
+    import typing
 
-    def deprecated(_message):
+    def deprecated(_message: str):
         """
         This is a noop; deprecation warnings are disabled for pre python
         3.13.

Reply via email to