diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pylifecycle.c | 20 | ||||
-rw-r--r-- | Python/stdlib_module_names.h (renamed from Python/module_names.h) | 6 | ||||
-rw-r--r-- | Python/sysmodule.c | 10 |
3 files changed, 18 insertions, 18 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index a97f45d0d5d..bf5dcdd107e 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2497,7 +2497,7 @@ fatal_error_exit(int status) // Dump the list of extension modules of sys.modules, excluding stdlib modules -// (sys.module_names), into fd file descriptor. +// (sys.stdlib_module_names), into fd file descriptor. // // This function is called by a signal handler in faulthandler: avoid memory // allocations and keep the implementation simple. For example, the list is not @@ -2519,19 +2519,19 @@ _Py_DumpExtensionModules(int fd, PyInterpreterState *interp) // Avoid PyDict_GetItemString() which calls PyUnicode_FromString(), // memory cannot be allocated on the heap in a signal handler. // Iterate on the dict instead. - PyObject *module_names = NULL; + PyObject *stdlib_module_names = NULL; pos = 0; while (PyDict_Next(interp->sysdict, &pos, &key, &value)) { if (PyUnicode_Check(key) - && PyUnicode_CompareWithASCIIString(key, "module_names") == 0) { - module_names = value; + && PyUnicode_CompareWithASCIIString(key, "stdlib_module_names") == 0) { + stdlib_module_names = value; break; } } - // If we failed to get sys.module_names or it's not a frozenset, + // If we failed to get sys.stdlib_module_names or it's not a frozenset, // don't exclude stdlib modules. - if (module_names != NULL && !PyFrozenSet_Check(module_names)) { - module_names = NULL; + if (stdlib_module_names != NULL && !PyFrozenSet_Check(stdlib_module_names)) { + stdlib_module_names = NULL; } // List extensions @@ -2547,13 +2547,13 @@ _Py_DumpExtensionModules(int fd, PyInterpreterState *interp) } // Use the module name from the sys.modules key, // don't attempt to get the module object name. - if (module_names != NULL) { + if (stdlib_module_names != NULL) { int is_stdlib_ext = 0; - Py_ssize_t i; + Py_ssize_t i = 0; PyObject *item; Py_hash_t hash; - for (i=0; _PySet_NextEntry(module_names, &i, &item, &hash); ) { + while (_PySet_NextEntry(stdlib_module_names, &i, &item, &hash)) { if (PyUnicode_Check(item) && PyUnicode_Compare(key, item) == 0) { diff --git a/Python/module_names.h b/Python/stdlib_module_names.h index 0dc2633916d..8c430821d64 100644 --- a/Python/module_names.h +++ b/Python/stdlib_module_names.h @@ -1,7 +1,7 @@ -// Auto-generated by Tools/scripts/generate_module_names.py. -// List used to create sys.module_names. +// Auto-generated by Tools/scripts/generate_stdlib_module_names.py. +// List used to create sys.stdlib_module_names. -static const char* _Py_module_names[] = { +static const char* _Py_stdlib_module_names[] = { "__future__", "_abc", "_aix_support", diff --git a/Python/sysmodule.c b/Python/sysmodule.c index e2f7e39f333..b9349effe3c 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -29,7 +29,7 @@ Data members: #include "frameobject.h" // PyFrame_GetBack() #include "pydtrace.h" #include "osdefs.h" // DELIM -#include "module_names.h" // _Py_module_names +#include "stdlib_module_names.h" // _Py_stdlib_module_names #include <locale.h> #ifdef MS_WINDOWS @@ -2054,16 +2054,16 @@ error: static PyObject * -list_module_names(void) +list_stdlib_module_names(void) { - Py_ssize_t len = Py_ARRAY_LENGTH(_Py_module_names); + Py_ssize_t len = Py_ARRAY_LENGTH(_Py_stdlib_module_names); PyObject *names = PyTuple_New(len); if (names == NULL) { return NULL; } for (Py_ssize_t i = 0; i < len; i++) { - PyObject *name = PyUnicode_FromString(_Py_module_names[i]); + PyObject *name = PyUnicode_FromString(_Py_stdlib_module_names[i]); if (name == NULL) { Py_DECREF(names); return NULL; @@ -2784,7 +2784,7 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict) SET_SYS("hash_info", get_hash_info(tstate)); SET_SYS("maxunicode", PyLong_FromLong(0x10FFFF)); SET_SYS("builtin_module_names", list_builtin_module_names()); - SET_SYS("module_names", list_module_names()); + SET_SYS("stdlib_module_names", list_stdlib_module_names()); #if PY_BIG_ENDIAN SET_SYS_FROM_STRING("byteorder", "big"); #else |