Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6049cb8

Browse files
committed
Simplify, and avoid PyModule_GetDict() while we're at it.
1 parent da5628f commit 6049cb8

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

Python/importdl.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern dl_funcptr _PyImport_GetDynLoadFunc(const char *name,
2121
PyObject *
2222
_PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
2323
{
24-
PyObject *m, *d, *s;
24+
PyObject *m;
2525
char *lastdot, *shortname, *packagecontext, *oldcontext;
2626
dl_funcptr p;
2727

@@ -64,11 +64,8 @@ _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
6464
return NULL;
6565
}
6666
/* Remember the filename as the __file__ attribute */
67-
d = PyModule_GetDict(m);
68-
s = PyString_FromString(pathname);
69-
if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0)
67+
if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
7068
PyErr_Clear(); /* Not important enough to report */
71-
Py_XDECREF(s);
7269
if (Py_VerboseFlag)
7370
PySys_WriteStderr(
7471
"import %s # dynamically loaded from %s\n",

0 commit comments

Comments
 (0)