Load commands and gdblib explicitly in __init__.py #1243
Merged
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.
For historical reasons, the modules in
pwndbg/commands
andpwndbg/gdblib
rely on executing code on import. This isn't great design, but we're stuck with it for now. At the very least, instead of importing a bunch of things inpwndbg/__init__.py
that aren't actually used in that file, we import them in the specific__init__.py
for that module inside a function, and then we just call that function to trigger the side effects of importing them.The remaining modules in
pwndbg/__init__.py
may also be able to be removed in the future, but for now I'm just lookinggdblib
andcommands
.Some motivations for this:
__init_.py
what is actually required to be imported for the code in that file, as opposed to side effectspwndbg.gdblib.ctypes
import, which was easy to spot with the reduced amount of imports.