aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/importlib/resources/_common.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2024-09-12 15:08:06 -0400
committerGitHub <noreply@github.com>2024-09-12 19:08:06 +0000
commita53812df126b99bca25187441a123c7785ee82a0 (patch)
treed46a8d6c7b85ffea776a527f72de2aeb4234c04a /Lib/importlib/resources/_common.py
parent8145ebea587284db3be3f152ee0298952977d6f4 (diff)
downloadcpython-a53812df126b99bca25187441a123c7785ee82a0.tar.gz
cpython-a53812df126b99bca25187441a123c7785ee82a0.zip
gh-123085: Fix issue in inferred caller when resources package has no source (#123102)
gh-123085: Fix issue in inferred caller when resources package has no source. From importlib_resources 6.4.3 (python/importlib_resources#314).
Diffstat (limited to 'Lib/importlib/resources/_common.py')
-rw-r--r--Lib/importlib/resources/_common.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/importlib/resources/_common.py b/Lib/importlib/resources/_common.py
index d5381fb80d8..c2c92254370 100644
--- a/Lib/importlib/resources/_common.py
+++ b/Lib/importlib/resources/_common.py
@@ -93,12 +93,13 @@ def _infer_caller():
"""
def is_this_file(frame_info):
- return frame_info.filename == __file__
+ return frame_info.filename == stack[0].filename
def is_wrapper(frame_info):
return frame_info.function == 'wrapper'
- not_this_file = itertools.filterfalse(is_this_file, inspect.stack())
+ stack = inspect.stack()
+ not_this_file = itertools.filterfalse(is_this_file, stack)
# also exclude 'wrapper' due to singledispatch in the call stack
callers = itertools.filterfalse(is_wrapper, not_this_file)
return next(callers).frame