One last rename glitch: import_modules -> _PyImport_Modules.

This commit is contained in:
Guido van Rossum 1997-05-14 17:36:12 +00:00
parent 39d6ae7b6c
commit af5dfb4ceb
3 changed files with 17 additions and 17 deletions

View File

@ -61,7 +61,7 @@ extern long PyOS_GetLastModificationTime(); /* In getmtime.c */
/* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */ /* New way to come up with the magic number: (YEAR-1995), MONTH, DAY */
#define MAGIC (20121 | ((long)'\r'<<16) | ((long)'\n'<<24)) #define MAGIC (20121 | ((long)'\r'<<16) | ((long)'\n'<<24))
PyObject *import_modules; /* This becomes sys.modules */ PyObject *_PyImport_Modules; /* This becomes sys.modules */
/* Initialize things */ /* Initialize things */
@ -69,9 +69,9 @@ PyObject *import_modules; /* This becomes sys.modules */
void void
PyImport_Init() PyImport_Init()
{ {
if (import_modules != NULL) if (_PyImport_Modules != NULL)
Py_FatalError("duplicate initimport() call"); Py_FatalError("duplicate initimport() call");
if ((import_modules = PyDict_New()) == NULL) if ((_PyImport_Modules = PyDict_New()) == NULL)
Py_FatalError("no mem for dictionary of modules"); Py_FatalError("no mem for dictionary of modules");
if (Py_OptimizeFlag) { if (Py_OptimizeFlag) {
/* Replace ".pyc" with ".pyo" in import_filetab */ /* Replace ".pyc" with ".pyo" in import_filetab */
@ -89,9 +89,9 @@ PyImport_Init()
void void
PyImport_Cleanup() PyImport_Cleanup()
{ {
if (import_modules != NULL) { if (_PyImport_Modules != NULL) {
PyObject *tmp = import_modules; PyObject *tmp = _PyImport_Modules;
import_modules = NULL; _PyImport_Modules = NULL;
/* This deletes all modules from sys.modules. /* This deletes all modules from sys.modules.
When a module is deallocated, it in turn clears its When a module is deallocated, it in turn clears its
dictionary, thus hopefully breaking any circular dictionary, thus hopefully breaking any circular
@ -118,7 +118,7 @@ PyImport_GetMagicNumber()
PyObject * PyObject *
PyImport_GetModuleDict() PyImport_GetModuleDict()
{ {
return import_modules; return _PyImport_Modules;
} }
@ -134,18 +134,18 @@ PyImport_AddModule(name)
{ {
PyObject *m; PyObject *m;
if (import_modules == NULL) { if (_PyImport_Modules == NULL) {
PyErr_SetString(PyExc_SystemError, PyErr_SetString(PyExc_SystemError,
"sys.modules has been deleted"); "sys.modules has been deleted");
return NULL; return NULL;
} }
if ((m = PyDict_GetItemString(import_modules, name)) != NULL && if ((m = PyDict_GetItemString(_PyImport_Modules, name)) != NULL &&
PyModule_Check(m)) PyModule_Check(m))
return m; return m;
m = PyModule_New(name); m = PyModule_New(name);
if (m == NULL) if (m == NULL)
return NULL; return NULL;
if (PyDict_SetItemString(import_modules, name, m) != 0) { if (PyDict_SetItemString(_PyImport_Modules, name, m) != 0) {
Py_DECREF(m); Py_DECREF(m);
return NULL; return NULL;
} }
@ -661,12 +661,12 @@ PyImport_ImportModule(name)
{ {
PyObject *m; PyObject *m;
if (import_modules == NULL) { if (_PyImport_Modules == NULL) {
PyErr_SetString(PyExc_SystemError, PyErr_SetString(PyExc_SystemError,
"sys.modules has been deleted"); "sys.modules has been deleted");
return NULL; return NULL;
} }
if ((m = PyDict_GetItemString(import_modules, name)) != NULL) { if ((m = PyDict_GetItemString(_PyImport_Modules, name)) != NULL) {
Py_INCREF(m); Py_INCREF(m);
} }
else { else {
@ -675,7 +675,7 @@ PyImport_ImportModule(name)
(i = PyImport_ImportFrozenModule(name))) { (i = PyImport_ImportFrozenModule(name))) {
if (i < 0) if (i < 0)
return NULL; return NULL;
if ((m = PyDict_GetItemString(import_modules, if ((m = PyDict_GetItemString(_PyImport_Modules,
name)) == NULL) { name)) == NULL) {
if (PyErr_Occurred() == NULL) if (PyErr_Occurred() == NULL)
PyErr_SetString(PyExc_SystemError, PyErr_SetString(PyExc_SystemError,
@ -710,12 +710,12 @@ PyImport_ReloadModule(m)
name = PyModule_GetName(m); name = PyModule_GetName(m);
if (name == NULL) if (name == NULL)
return NULL; return NULL;
if (import_modules == NULL) { if (_PyImport_Modules == NULL) {
PyErr_SetString(PyExc_SystemError, PyErr_SetString(PyExc_SystemError,
"sys.modules has been deleted"); "sys.modules has been deleted");
return NULL; return NULL;
} }
if (m != PyDict_GetItemString(import_modules, name)) { if (m != PyDict_GetItemString(_PyImport_Modules, name)) {
PyErr_SetString(PyExc_ImportError, PyErr_SetString(PyExc_ImportError,
"reload() module not in sys.modules"); "reload() module not in sys.modules");
return NULL; return NULL;

View File

@ -527,7 +527,7 @@ _PyImport_LoadDynamicModule(name, pathname, fp)
(*p)(); (*p)();
/* XXX Need check for err_occurred() here */ /* XXX Need check for err_occurred() here */
m = PyDict_GetItemString(import_modules, name); m = PyDict_GetItemString(_PyImport_Modules, name);
if (m == NULL) { if (m == NULL) {
if (PyErr_Occurred() == NULL) if (PyErr_Occurred() == NULL)
PyErr_SetString(PyExc_SystemError, PyErr_SetString(PyExc_SystemError,

View File

@ -42,7 +42,7 @@ extern struct filedescr {
enum filetype type; enum filetype type;
} _PyImport_Filetab[]; } _PyImport_Filetab[];
extern PyObject *import_modules; extern PyObject *_PyImport_Modules;
extern PyObject *_PyImport_LoadDynamicModule extern PyObject *_PyImport_LoadDynamicModule
Py_PROTO((char *name, char *pathname, FILE *)); Py_PROTO((char *name, char *pathname, FILE *));