mirror of
https://github.com/python/cpython.git
synced 2025-11-17 17:46:45 +00:00
Simplify, and avoid PyModule_GetDict() while we're at it.
This commit is contained in:
parent
da5628f286
commit
6049cb8918
1 changed files with 2 additions and 5 deletions
|
|
@ -21,7 +21,7 @@ extern dl_funcptr _PyImport_GetDynLoadFunc(const char *name,
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
|
_PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
|
||||||
{
|
{
|
||||||
PyObject *m, *d, *s;
|
PyObject *m;
|
||||||
char *lastdot, *shortname, *packagecontext, *oldcontext;
|
char *lastdot, *shortname, *packagecontext, *oldcontext;
|
||||||
dl_funcptr p;
|
dl_funcptr p;
|
||||||
|
|
||||||
|
|
@ -64,11 +64,8 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Remember the filename as the __file__ attribute */
|
/* Remember the filename as the __file__ attribute */
|
||||||
d = PyModule_GetDict(m);
|
if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
|
||||||
s = PyString_FromString(pathname);
|
|
||||||
if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0)
|
|
||||||
PyErr_Clear(); /* Not important enough to report */
|
PyErr_Clear(); /* Not important enough to report */
|
||||||
Py_XDECREF(s);
|
|
||||||
if (Py_VerboseFlag)
|
if (Py_VerboseFlag)
|
||||||
PySys_WriteStderr(
|
PySys_WriteStderr(
|
||||||
"import %s # dynamically loaded from %s\n",
|
"import %s # dynamically loaded from %s\n",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue