Lines Matching defs:modules
446 * extension modules), so we make sure that they match the locale
771 if (_PyImport_FixupBuiltin(bimod, "builtins", interp->modules) < 0) {
839 // Intern strings in deep-frozen modules first so that others
842 return _PyStatus_ERR("failed to initialize deep-frozen modules");
878 /* sys.modules['sys'] contains a strong reference to the module */
1026 * The import system will support builtin and frozen modules only.
1107 * This means anything which needs support from extension modules
1377 finalize_remove_modules(PyObject *modules, int verbose)
1406 if (PyObject_SetItem(modules, name, Py_None) < 0) { \
1411 if (PyDict_CheckExact(modules)) {
1414 while (PyDict_Next(modules, &pos, &key, &value)) {
1419 PyObject *iterator = PyObject_GetIter(modules);
1426 PyObject *value = PyObject_GetItem(modules, key);
1449 finalize_clear_modules_dict(PyObject *modules)
1451 if (PyDict_CheckExact(modules)) {
1452 PyDict_Clear(modules);
1455 if (PyObject_CallMethodNoArgs(modules, &_Py_ID(clear)) == NULL) {
1482 // First clear modules imported later
1522 /* Clear modules, as good as we can */
1527 PyObject *modules = interp->modules;
1528 if (modules == NULL) {
1536 // destructors fail. Since the modules containing them are
1543 // Remove all modules from sys.modules, hoping that garbage collection
1544 // can reclaim most of them: set all sys.modules values to None.
1547 // modules when they are removed from sys.modules. The name is used
1549 // detect those modules which have been held alive.
1550 PyObject *weaklist = finalize_remove_modules(modules, verbose);
1552 // Clear the modules dict
1553 finalize_clear_modules_dict(modules);
1567 // Now, if there are any modules left alive, clear their globals to
1568 // minimize potential leaks. All C extension modules actually end
1579 // Since dict is ordered in CPython 3.6+, modules are saved in
1580 // importing order. First clear modules imported later.
1585 // Clear sys and builtins modules dict
1594 // Clear and delete the modules directory. Actual modules will
1597 Py_SETREF(interp->modules, NULL);
1819 * before all modules are destroyed.
1832 /* Destroy all modules */
2634 // Dump the list of extension modules of sys.modules, excluding stdlib modules
2646 PyObject *modules = interp->modules;
2647 if (modules == NULL || !PyDict_Check(modules)) {
2669 // don't exclude stdlib modules.
2678 while (PyDict_Next(modules, &pos, &key, &value)) {
2685 // Use the module name from the sys.modules key,
2708 PUTS(fd, "\nExtension modules: ");