]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-140633: AppleFrameworkLoader: Ignore AttributeError when setting __file__...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 27 Oct 2025 13:08:09 +0000 (14:08 +0100)
committerGitHub <noreply@github.com>
Mon, 27 Oct 2025 13:08:09 +0000 (14:08 +0100)
(cherry picked from commit 3416e7c8dc004773d814b6f9ec9562434ed961cd)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Lib/importlib/_bootstrap_external.py
Misc/NEWS.d/next/Library/2025-10-26-16-24-12.gh-issue-140633.ioayC1.rst [new file with mode: 0644]

index c5e641773e6c5e61106123208bcc42f465d7988c..ad9a1a391a4b40ed9fec744b0ef441454114f992 100644 (file)
@@ -1762,7 +1762,13 @@ class AppleFrameworkLoader(ExtensionFileLoader):
         )
 
         # Ensure that the __file__ points at the .fwork location
-        module.__file__ = path
+        try:
+            module.__file__ = path
+        except AttributeError:
+            # Not important enough to report.
+            # (The error is also ignored in _bootstrap._init_module_attrs or
+            # import_run_extension in import.c)
+            pass
 
         return module
 
diff --git a/Misc/NEWS.d/next/Library/2025-10-26-16-24-12.gh-issue-140633.ioayC1.rst b/Misc/NEWS.d/next/Library/2025-10-26-16-24-12.gh-issue-140633.ioayC1.rst
new file mode 100644 (file)
index 0000000..9675a5d
--- /dev/null
@@ -0,0 +1,2 @@
+Ignore :exc:`AttributeError` when setting a module's ``__file__`` attribute
+when loading an extension module packaged as Apple Framework.