diff options
author | Georg Brandl <georg@python.org> | 2007-12-02 09:40:06 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-12-02 09:40:06 (GMT) |
commit | 1a3284ed69d545e4ef59869998cb8c29233a45fa (patch) | |
tree | 98728a9b7aae6188ee8124160007a9d5c5277f8c /Python | |
parent | 87f9c53937ce47f55851ac7c71a94e46cf9142bf (diff) | |
download | cpython-1a3284ed69d545e4ef59869998cb8c29233a45fa.zip cpython-1a3284ed69d545e4ef59869998cb8c29233a45fa.tar.gz cpython-1a3284ed69d545e4ef59869998cb8c29233a45fa.tar.bz2 |
#1535: rename __builtin__ module to builtins.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/bltinmodule.c | 4 | ||||
-rw-r--r-- | Python/errors.c | 2 | ||||
-rw-r--r-- | Python/import.c | 26 | ||||
-rw-r--r-- | Python/pythonrun.c | 16 | ||||
-rw-r--r-- | Python/sysmodule.c | 8 |
5 files changed, 28 insertions, 28 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index fb7e223..053e083 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1851,7 +1851,7 @@ PyObject * _PyBuiltin_Init(void) { PyObject *mod, *dict, *debug; - mod = Py_InitModule4("__builtin__", builtin_methods, + mod = Py_InitModule4("builtins", builtin_methods, builtin_doc, (PyObject *)NULL, PYTHON_API_VERSION); if (mod == NULL) @@ -1859,7 +1859,7 @@ _PyBuiltin_Init(void) dict = PyModule_GetDict(mod); #ifdef Py_TRACE_REFS - /* __builtin__ exposes a number of statically allocated objects + /* "builtins" exposes a number of statically allocated objects * that, before this code was added in 2.3, never showed up in * the list of "all objects" maintained by Py_TRACE_REFS. As a * result, programs leaking references to None and False (etc) diff --git a/Python/errors.c b/Python/errors.c index 1cd5dfd..063187b 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -645,7 +645,7 @@ PyErr_WriteUnraisable(PyObject *obj) else { char* modstr = PyUnicode_AsString(moduleName); if (modstr && - strcmp(modstr, "__builtin__") != 0) + strcmp(modstr, "builtins") != 0) { PyFile_WriteString(modstr, f); PyFile_WriteString(".", f); diff --git a/Python/import.c b/Python/import.c index 1ea9297..419f3e9 100644 --- a/Python/import.c +++ b/Python/import.c @@ -400,11 +400,11 @@ PyImport_Cleanup(void) deleted *last* of all, they would come too late in the normal destruction order. Sigh. */ - value = PyDict_GetItemString(modules, "__builtin__"); + value = PyDict_GetItemString(modules, "builtins"); if (value != NULL && PyModule_Check(value)) { dict = PyModule_GetDict(value); if (Py_VerboseFlag) - PySys_WriteStderr("# clear __builtin__._\n"); + PySys_WriteStderr("# clear builtins._\n"); PyDict_SetItemString(dict, "_", Py_None); } value = PyDict_GetItemString(modules, "sys"); @@ -436,11 +436,11 @@ PyImport_Cleanup(void) PyDict_SetItemString(modules, "__main__", Py_None); } - /* The special treatment of __builtin__ here is because even + /* The special treatment of "builtins" here is because even when it's not referenced as a module, its dictionary is referenced by almost every module's __builtins__. Since deleting a module clears its dictionary (even if there are - references left to it), we need to delete the __builtin__ + references left to it), we need to delete the "builtins" module last. Likewise, we don't delete sys until the very end because it is implicitly referenced (e.g. by print). @@ -451,7 +451,7 @@ PyImport_Cleanup(void) re-imported. */ /* Next, repeatedly delete modules with a reference count of - one (skipping __builtin__ and sys) and delete them */ + one (skipping builtins and sys) and delete them */ do { ndone = 0; pos = 0; @@ -460,7 +460,7 @@ PyImport_Cleanup(void) continue; if (PyUnicode_Check(key) && PyModule_Check(value)) { name = PyUnicode_AsString(key); - if (strcmp(name, "__builtin__") == 0) + if (strcmp(name, "builtins") == 0) continue; if (strcmp(name, "sys") == 0) continue; @@ -474,12 +474,12 @@ PyImport_Cleanup(void) } } while (ndone > 0); - /* Next, delete all modules (still skipping __builtin__ and sys) */ + /* Next, delete all modules (still skipping builtins and sys) */ pos = 0; while (PyDict_Next(modules, &pos, &key, &value)) { if (PyUnicode_Check(key) && PyModule_Check(value)) { name = PyUnicode_AsString(key); - if (strcmp(name, "__builtin__") == 0) + if (strcmp(name, "builtins") == 0) continue; if (strcmp(name, "sys") == 0) continue; @@ -490,7 +490,7 @@ PyImport_Cleanup(void) } } - /* Next, delete sys and __builtin__ (in that order) */ + /* Next, delete sys and builtins (in that order) */ value = PyDict_GetItemString(modules, "sys"); if (value != NULL && PyModule_Check(value)) { if (Py_VerboseFlag) @@ -498,12 +498,12 @@ PyImport_Cleanup(void) _PyModule_Clear(value); PyDict_SetItemString(modules, "sys", Py_None); } - value = PyDict_GetItemString(modules, "__builtin__"); + value = PyDict_GetItemString(modules, "builtins"); if (value != NULL && PyModule_Check(value)) { if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup __builtin__\n"); + PySys_WriteStderr("# cleanup builtins\n"); _PyModule_Clear(value); - PyDict_SetItemString(modules, "__builtin__", Py_None); + PyDict_SetItemString(modules, "builtins", Py_None); } /* Finally, clear and delete the modules directory */ @@ -2491,7 +2491,7 @@ PyImport_Import(PyObject *module_name) /* No globals -- use standard builtins, and fake globals */ PyErr_Clear(); - builtins = PyImport_ImportModuleLevel("__builtin__", + builtins = PyImport_ImportModuleLevel("builtins", NULL, NULL, NULL, 0); if (builtins == NULL) return NULL; diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 08b0d83..d1a062b 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -211,7 +211,7 @@ Py_InitializeEx(int install_sigs) bimod = _PyBuiltin_Init(); if (bimod == NULL) - Py_FatalError("Py_Initialize: can't initialize __builtin__"); + Py_FatalError("Py_Initialize: can't initialize builtins modules"); interp->builtins = PyModule_GetDict(bimod); if (interp->builtins == NULL) Py_FatalError("Py_Initialize: can't initialize builtins dict"); @@ -243,7 +243,7 @@ Py_InitializeEx(int install_sigs) _PyImport_Init(); /* phase 2 of builtins */ - _PyImport_FixupExtension("__builtin__", "__builtin__"); + _PyImport_FixupExtension("builtins", "builtins"); _PyImportHooks_Init(); @@ -572,7 +572,7 @@ Py_NewInterpreter(void) interp->modules = PyDict_New(); interp->modules_reloading = PyDict_New(); - bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); + bimod = _PyImport_FindExtension("builtins", "builtins"); if (bimod != NULL) { interp->builtins = PyModule_GetDict(bimod); if (interp->builtins == NULL) @@ -682,7 +682,7 @@ initmain(void) Py_FatalError("can't create __main__ module"); d = PyModule_GetDict(m); if (PyDict_GetItemString(d, "__builtins__") == NULL) { - PyObject *bimod = PyImport_ImportModule("__builtin__"); + PyObject *bimod = PyImport_ImportModule("builtins"); if (bimod == NULL || PyDict_SetItemString(d, "__builtins__", bimod) != 0) Py_FatalError("can't add __builtins__ to __main__"); @@ -717,7 +717,7 @@ initsite(void) } } -/* Initialize sys.stdin, stdout, stderr and __builtin__.open */ +/* Initialize sys.stdin, stdout, stderr and builtins.open */ static int initstdio(void) { @@ -739,7 +739,7 @@ initstdio(void) } Py_DECREF(m); - if (!(bimod = PyImport_ImportModule("__builtin__"))) { + if (!(bimod = PyImport_ImportModule("builtins"))) { goto error; } @@ -750,7 +750,7 @@ initstdio(void) goto error; } - /* Set __builtin__.open */ + /* Set builtins.open */ if (PyObject_SetAttrString(bimod, "open", wrapper) == -1) { goto error; } @@ -1362,7 +1362,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb) } else { char* modstr = PyUnicode_AsString(moduleName); - if (modstr && strcmp(modstr, "__builtin__")) + if (modstr && strcmp(modstr, "builtins")) { err = PyFile_WriteString(modstr, f); err += PyFile_WriteString(".", f); diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 6f68e00..e793707 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -72,10 +72,10 @@ sys_displayhook(PyObject *self, PyObject *o) PyObject *outf; PyInterpreterState *interp = PyThreadState_GET()->interp; PyObject *modules = interp->modules; - PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); + PyObject *builtins = PyDict_GetItemString(modules, "builtins"); if (builtins == NULL) { - PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); + PyErr_SetString(PyExc_RuntimeError, "lost builtins module"); return NULL; } @@ -106,7 +106,7 @@ sys_displayhook(PyObject *self, PyObject *o) PyDoc_STRVAR(displayhook_doc, "displayhook(object) -> None\n" "\n" -"Print an object to sys.stdout and also save it in __builtin__.\n" +"Print an object to sys.stdout and also save it in builtins.\n" ); static PyObject * @@ -896,7 +896,7 @@ __excepthook__ -- the original excepthook; don't touch!\n\ \n\ Functions:\n\ \n\ -displayhook() -- print an object to the screen, and save it in __builtin__._\n\ +displayhook() -- print an object to the screen, and save it in builtins._\n\ excepthook() -- print an exception and its traceback to sys.stderr\n\ exc_info() -- return thread-safe information about the current exception\n\ exit() -- exit the interpreter by raising SystemExit\n\ |