Skip to content

Commit 9ba60f0

Browse files
committed
Move _caller above sentinel
Sentinels _marker requires _caller in order to remove its module_name
1 parent bf59ce3 commit 9ba60f0

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

src/typing_extensions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff 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+
377389
class 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

0 commit comments

Comments
 (0)