Repository navigation
Re-Loading the sys or builtins Modules is Problematic #102660
Copy link
Copy link
Open
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-subinterpreterstype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancementinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)3.12only security fixesonly security fixes
on Mar 13, 2023 - added a commit that references this issue
on Mar 14, 2023 ericsnowcurrently commented
on Mar 14, 2023 MemberAuthorMore actionsI'm leaving this open since we haven't settled whether or not we should disallow directly loading sys/builtins. (That isn't critical to settle in the short-term, so I'm not going to focus much on it for now.)
- added a commit that references this issue
on Mar 14, 2023 - added a commit that references this issue
on Mar 16, 2023 - added a commit that references this issue
on Mar 17, 2023 Triage: can this be closed or is there more to do?
Edit: I see this was recently move to "Todo" so sounds like there is more. Thanks!
Reacted by Eric Snow
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-subinterpreterstype-featureA feature request or enhancementA feature request or enhancement
Projects
- StatusShow more project fieldsTodo
The
sysandbuiltinsmodules 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