Re-Loading the sys or builtins Modules is Problematic · Issue #102660 · python/cpython (original) (raw)

The sys and builtins modules are special in that they are initialized early in interpreter startup, mostly before the import system. They aren't initialized like other modules. Furthermore, the data they expose is fundamental to the interpreter. Reloading the modules doesn't make much sense.

The simplest thing to do is to disallow manually loading them (e.g. via the loader). At the very least we should handle m_copy for these modules carefully. (This came up while working on gh-101660.)

Linked PRs