-
-
Couldn't load subscription status.
- Fork 33.3k
Open
Labels
OS-iosstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
When loading a module whose Py_mod_create function returns an immutable non-module object, AppleFrameworkLoader raises an exception:
Traceback (most recent call last):
File "/Users/buildbot/Library/Developer/CoreSimulator/Devices/4A7F2ACB-DEB3-48C5-83AB-082A7477C83B/data/Containers/Bundle/Application/36F469DF-8636-4BCC-90FC-A40A316E94B6/iOSTestbed.app/python/lib/python3.15/test/test_import/__init__.py", line 137, in import_extension_from_file
module = importlib.util.module_from_spec(spec)
File "<frozen importlib._bootstrap>", line 816, in module_from_spec
module = spec.loader.create_module(spec)
File "<frozen importlib._bootstrap_external>", line 1509, in create_module
module.__file__ = path
AttributeError: 'str' object has no attribute '__file__' and no __dict__ for setting new attributes. Did you mean: '__le__'?
Other places that set this (importlib._bootstrap._init_module_attrs, import.c's import_run_extension) ignore AttributeError here.
(Hmm... Should __spec__.origin be set here?)
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
OS-iosstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error