diff Python/importdl.c @ 25040:db49ee76b7d0 legacy-trunk

Simplify, and avoid PyModule_GetDict() while we're at it.
author Fred Drake <fdrake@acm.org>
date Mon, 26 Aug 2002 21:15:11 +0000
parents 2f0c5af4d5ea
children 19611d101d23
line wrap: on
line diff
--- a/Python/importdl.c	Mon Aug 26 16:44:56 2002 +0000
+++ b/Python/importdl.c	Mon Aug 26 21:15:11 2002 +0000
@@ -21,7 +21,7 @@
 PyObject *
 _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
 {
-	PyObject *m, *d, *s;
+	PyObject *m;
 	char *lastdot, *shortname, *packagecontext, *oldcontext;
 	dl_funcptr p;
 
@@ -64,11 +64,8 @@
 		return NULL;
 	}
 	/* Remember the filename as the __file__ attribute */
-	d = PyModule_GetDict(m);
-	s = PyString_FromString(pathname);
-	if (s == NULL || PyDict_SetItemString(d, "__file__", s) != 0)
+	if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
 		PyErr_Clear(); /* Not important enough to report */
-	Py_XDECREF(s);
 	if (Py_VerboseFlag)
 		PySys_WriteStderr(
 			"import %s # dynamically loaded from %s\n",