-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-28411: Remove "modules" field from Py_InterpreterState. #1638
Merged
ericsnowcurrently
merged 35 commits into
python:master
from
ericsnowcurrently:remove-modules-from-interpreter-state
Sep 4, 2017
+261
−111
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
70f6e19
Add _PyImport_GetModuleDict().
ericsnowcurrently 10f7443
Import the sys module before any other imports.
ericsnowcurrently 5ea0e3b
Pass the modules dict to _PyImport_FindBuiltin().
ericsnowcurrently 29780ec
Replace usage of interp->modules with PyImport_GetModuleDict().
ericsnowcurrently e6de215
Add _PyImport_EnsureInitialized().
ericsnowcurrently 29f6b7c
Add _PyModule_Create2().
ericsnowcurrently b77d73f
Use _PyModule_Create2() for key builtin modules.
ericsnowcurrently 8275633
Check sys.modules in _PyImport_EnsureInitialized().
ericsnowcurrently 7c62114
Drop PyInterpreterState.modules.
ericsnowcurrently 428d223
Pass the modules dict to _PyImport_FixupBuiltin().
ericsnowcurrently 833b00b
Pass PyInterpreterState to _PyImport_GetModuleDict().
ericsnowcurrently e0e51d2
Drop _PyImport_GetModuleDict().
ericsnowcurrently 88aadeb
_PyModule_Create2 -> _PyModule_CreateInitialized
ericsnowcurrently 79320bd
_PyImport_EnsureInitialized() -> _PyImport_IsInitialized()
ericsnowcurrently 6a0215c
Add _PyImport_GetModule*.
ericsnowcurrently dabd187
Allow sys.modules to be any mapping.
ericsnowcurrently 58d9be7
Add _PyImport_SetModule*.
ericsnowcurrently e3b0f0c
Add PyImport_GetModule().
ericsnowcurrently d9c6b79
Fix ref counts.
ericsnowcurrently e3565f9
Look up "new" modules in the given modules dict.
ericsnowcurrently 9946341
Fix error checking.
ericsnowcurrently 08e556e
Use PyImport_GetModuleDict() in PyImport_GetModule().
ericsnowcurrently f043e47
Decref the module when done.
ericsnowcurrently b2edd25
Add a missing incref.
ericsnowcurrently 0eced28
Fix post-rebase.
ericsnowcurrently a85a11f
Add a Misc/NEWS entry.
ericsnowcurrently 9ba4c43
Make the docs for PyImport_GetModule() more clear.
ericsnowcurrently f837a61
Fix style (bracket placement).
ericsnowcurrently 101aa31
Drop _PyImport_GetModuleString().
ericsnowcurrently 8f8a7a2
Use PyDict_CheckExact() for sys.modules in fast case.
ericsnowcurrently 3a56648
Do not use PyMapping_HasKey() with an error set.
ericsnowcurrently 619b0a0
Revert a code order change.
ericsnowcurrently 57eeb5b
Drop _PyImport_FixupExtensionObjectEx().
ericsnowcurrently 6544fa2
Switch the code order back.
ericsnowcurrently 8e86c53
Add a whatsnew entry for porting.
ericsnowcurrently File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add _PyImport_SetModule*.
commit 58d9be77a0ae6ab7d80ac740158a17db86f70477
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -369,6 +369,18 @@ _PyImport_GetModuleId(struct _Py_Identifier *nameid) | |
return _PyImport_GetModule(name); | ||
} | ||
|
||
int | ||
_PyImport_SetModule(PyObject *name, PyObject *m) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put { on a new line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
PyObject *modules = PyImport_GetModuleDict(); | ||
return PyObject_SetItem(modules, name, m); | ||
} | ||
|
||
int | ||
_PyImport_SetModuleString(const char *name, PyObject *m) { | ||
PyObject *modules = PyImport_GetModuleDict(); | ||
return PyMapping_SetItemString(modules, name, m); | ||
} | ||
|
||
|
||
/* List of names to clear in sys */ | ||
static const char * const sys_deletes[] = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't tink that it's worth it to add _PyImport_GetModuleString(): it's only used 2 times. Please use _PyImport_GetModuleId() with_Py_IDENTIFIER, and remove _PyImport_GetModuleString(). I dislike having N versions of the same function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll drop it.