File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -374,6 +374,18 @@ def wrapper(*args, **kwargs):
374374 )
375375
376376
377+ def _caller (depth = 1 , default = '__main__' ):
378+ try :
379+ return sys ._getframemodulename (depth + 1 ) or default
380+ except AttributeError : # For platforms without _getframemodulename()
381+ pass
382+ try :
383+ return sys ._getframe (depth + 1 ).f_globals .get ('__name__' , default )
384+ except (AttributeError , ValueError ): # For platforms without _getframe()
385+ pass
386+ return None
387+
388+
377389class Sentinel :
378390 """Create a unique sentinel object.
379391
@@ -793,18 +805,6 @@ def _get_protocol_attrs(cls):
793805 return attrs
794806
795807
796- def _caller (depth = 1 , default = '__main__' ):
797- try :
798- return sys ._getframemodulename (depth + 1 ) or default
799- except AttributeError : # For platforms without _getframemodulename()
800- pass
801- try :
802- return sys ._getframe (depth + 1 ).f_globals .get ('__name__' , default )
803- except (AttributeError , ValueError ): # For platforms without _getframe()
804- pass
805- return None
806-
807-
808808# `__match_args__` attribute was removed from protocol members in 3.13,
809809# we want to backport this change to older Python versions.
810810# Breakpoint: https://github.com/python/cpython/pull/110683
You can’t perform that action at this time.
0 commit comments