summaryrefslogtreecommitdiffstats
path: root/Python/importdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/importdl.c')
-rw-r--r--Python/importdl.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/Python/importdl.c b/Python/importdl.c
index a309194..38f56db 100644
--- a/Python/importdl.c
+++ b/Python/importdl.c
@@ -111,9 +111,12 @@ _Py_ext_module_loader_info_clear(struct _Py_ext_module_loader_info *info)
int
_Py_ext_module_loader_info_init(struct _Py_ext_module_loader_info *p_info,
- PyObject *name, PyObject *filename)
+ PyObject *name, PyObject *filename,
+ _Py_ext_module_origin origin)
{
- struct _Py_ext_module_loader_info info = {0};
+ struct _Py_ext_module_loader_info info = {
+ .origin=origin,
+ };
assert(name != NULL);
if (!PyUnicode_Check(name)) {
@@ -183,6 +186,7 @@ _Py_ext_module_loader_info_init_for_builtin(
.name_encoded=name_encoded,
/* We won't need filename. */
.path=name,
+ .origin=_Py_ext_module_origin_BUILTIN,
.hook_prefix=ascii_only_prefix,
.newcontext=NULL,
};
@@ -190,6 +194,18 @@ _Py_ext_module_loader_info_init_for_builtin(
}
int
+_Py_ext_module_loader_info_init_for_core(
+ struct _Py_ext_module_loader_info *info,
+ PyObject *name)
+{
+ if (_Py_ext_module_loader_info_init_for_builtin(info, name) < 0) {
+ return -1;
+ }
+ info->origin = _Py_ext_module_origin_CORE;
+ return 0;
+}
+
+int
_Py_ext_module_loader_info_init_from_spec(
struct _Py_ext_module_loader_info *p_info,
PyObject *spec)
@@ -203,7 +219,9 @@ _Py_ext_module_loader_info_init_from_spec(
Py_DECREF(name);
return -1;
}
- int err = _Py_ext_module_loader_info_init(p_info, name, filename);
+ /* We could also accommodate builtin modules here without much trouble. */
+ _Py_ext_module_origin origin = _Py_ext_module_origin_DYNAMIC;
+ int err = _Py_ext_module_loader_info_init(p_info, name, filename, origin);
Py_DECREF(name);
Py_DECREF(filename);
return err;