Last active
May 23, 2024 18:10
-
-
Save secemp9/ca83bbec6728e5196fe96b76c3f6fc66 to your computer and use it in GitHub Desktop.
reload sys module (doesn't actually work it turn out :/)
This file contains hidden or 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
| import sys | |
| import importlib | |
| sys.exit = lambda *args, **kwargs: ... | |
| print(f"sys.exit overridden: {sys.exit}") | |
| importlib.reload(sys) | |
| print(f"sys.exit restored: {sys.exit}") | |
| try: | |
| print("test") | |
| sys.exit(0) | |
| except SystemExit as e: | |
| print(f"SystemExit caught with code: {e.code}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment