aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2024-03-19 20:36:19 +0800
committerGitHub <noreply@github.com>2024-03-19 08:36:19 -0400
commit408e127159e54d87bb3464fd8bd60219dc527fac (patch)
tree055bc39042521f314a7d225a22b3ca8ce403d453 /Lib/inspect.py
parenta5574789876987b2b9aa19294c735fe795a5b5c4 (diff)
downloadcpython-408e127159e54d87bb3464fd8bd60219dc527fac.tar.gz
cpython-408e127159e54d87bb3464fd8bd60219dc527fac.zip
gh-114099 - Add iOS framework loading machinery. (GH-116454)
Co-authored-by: Malcolm Smith <smith@chaquo.com> Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 8a2b2c96e99..7336cea0dc3 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -954,6 +954,10 @@ def getsourcefile(object):
elif any(filename.endswith(s) for s in
importlib.machinery.EXTENSION_SUFFIXES):
return None
+ elif filename.endswith(".fwork"):
+ # Apple mobile framework markers are another type of non-source file
+ return None
+
# return a filename found in the linecache even if it doesn't exist on disk
if filename in linecache.cache:
return filename
@@ -984,6 +988,7 @@ def getmodule(object, _filename=None):
return object
if hasattr(object, '__module__'):
return sys.modules.get(object.__module__)
+
# Try the filename to modulename cache
if _filename is not None and _filename in modulesbyfile:
return sys.modules.get(modulesbyfile[_filename])
@@ -1119,7 +1124,7 @@ def findsource(object):
# Allow filenames in form of "<something>" to pass through.
# `doctest` monkeypatches `linecache` module to enable
# inspection, so let `linecache.getlines` to be called.
- if not (file.startswith('<') and file.endswith('>')):
+ if (not (file.startswith('<') and file.endswith('>'))) or file.endswith('.fwork'):
raise OSError('source code not available')
module = getmodule(object, file)