Skip to content

Commit 5d951b3

Browse files
path -> filename
1 parent d5f97e7 commit 5d951b3

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

Include/internal/pycore_importdl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ extern const char *_PyImport_DynLoadFiletab[];
1818
typedef PyObject *(*PyModInitFunction)(void);
1919

2020
struct _Py_ext_module_loader_info {
21-
PyObject *path;
21+
PyObject *filename;
2222
#ifndef MS_WINDOWS
23-
PyObject *path_encoded;
23+
PyObject *filename_encoded;
2424
#endif
2525
PyObject *name;
2626
PyObject *name_encoded;

Python/import.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,13 +3887,13 @@ _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file)
38873887
}
38883888

38893889
PyThreadState *tstate = _PyThreadState_GET();
3890-
mod = import_find_extension(tstate, info.name, info.path);
3890+
mod = import_find_extension(tstate, info.name, info.filename);
38913891
if (mod != NULL || _PyErr_Occurred(tstate)) {
38923892
assert(mod == NULL || !_PyErr_Occurred(tstate));
38933893
goto finally;
38943894
}
38953895

3896-
if (PySys_Audit("import", "OOOOO", info.name, info.path,
3896+
if (PySys_Audit("import", "OOOOO", info.name, info.filename,
38973897
Py_None, Py_None, Py_None) < 0)
38983898
{
38993899
goto finally;
@@ -3905,7 +3905,7 @@ _imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file)
39053905
* _PyImport_GetModInitFunc(), but it isn't clear if the intervening
39063906
* code relies on fp still being open. */
39073907
if (file != NULL) {
3908-
fp = _Py_fopen_obj(info.path, "r");
3908+
fp = _Py_fopen_obj(info.filename, "r");
39093909
if (fp == NULL) {
39103910
goto finally;
39113911
}

Python/importdl.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ get_encoded_name(PyObject *name, const char **hook_prefix) {
9696
void
9797
_Py_ext_module_loader_info_clear(struct _Py_ext_module_loader_info *info)
9898
{
99-
Py_CLEAR(info->path);
99+
Py_CLEAR(info->filename);
100100
#ifndef MS_WINDOWS
101-
Py_CLEAR(info->path_encoded);
101+
Py_CLEAR(info->filename_encoded);
102102
#endif
103103
Py_CLEAR(info->name);
104104
Py_CLEAR(info->name_encoded);
@@ -134,15 +134,15 @@ _Py_ext_module_loader_info_init_from_spec(
134134
return -1;
135135
}
136136

137-
info.path = PyObject_GetAttrString(spec, "origin");
138-
if (info.path == NULL) {
137+
info.filename = PyObject_GetAttrString(spec, "origin");
138+
if (info.filename == NULL) {
139139
_Py_ext_module_loader_info_clear(&info);
140140
return -1;
141141
}
142142

143143
#ifndef MS_WINDOWS
144-
info.path_encoded = PyUnicode_EncodeFSDefault(info.path);
145-
if (info.path_encoded == NULL) {
144+
info.filename_encoded = PyUnicode_EncodeFSDefault(info.filename);
145+
if (info.filename_encoded == NULL) {
146146
_Py_ext_module_loader_info_clear(&info);
147147
return -1;
148148
}
@@ -165,10 +165,10 @@ _PyImport_LoadDynamicModuleWithSpec(struct _Py_ext_module_loader_info *info,
165165

166166
#ifdef MS_WINDOWS
167167
exportfunc = _PyImport_FindSharedFuncptrWindows(
168-
info->hook_prefix, name_buf, info->path, fp);
168+
info->hook_prefix, name_buf, info->filename, fp);
169169
#else
170170
{
171-
const char *path_buf = PyBytes_AS_STRING(info->path_encoded);
171+
const char *path_buf = PyBytes_AS_STRING(info->filename_encoded);
172172
exportfunc = _PyImport_FindSharedFuncptr(
173173
info->hook_prefix, name_buf, path_buf, fp);
174174
}
@@ -182,7 +182,7 @@ _PyImport_LoadDynamicModuleWithSpec(struct _Py_ext_module_loader_info *info,
182182
"module export function (%s_%s)",
183183
info->hook_prefix, name_buf);
184184
if (msg != NULL) {
185-
PyErr_SetImportError(msg, info->name, info->path);
185+
PyErr_SetImportError(msg, info->name, info->filename);
186186
Py_DECREF(msg);
187187
}
188188
}
@@ -252,12 +252,14 @@ _PyImport_LoadDynamicModuleWithSpec(struct _Py_ext_module_loader_info *info,
252252
def->m_base.m_init = p0;
253253

254254
/* Remember the filename as the __file__ attribute */
255-
if (PyModule_AddObjectRef(m, "__file__", info->path) < 0) {
255+
if (PyModule_AddObjectRef(m, "__file__", info->filename) < 0) {
256256
PyErr_Clear(); /* Not important enough to report */
257257
}
258258

259259
PyObject *modules = PyImport_GetModuleDict();
260-
if (_PyImport_FixupExtensionObject(m, info->name, info->path, modules) < 0) {
260+
if (_PyImport_FixupExtensionObject(
261+
m, info->name, info->filename, modules) < 0)
262+
{
261263
goto error;
262264
}
263265

0 commit comments

Comments
 (0)