Skip to content

Instantly share code, notes, and snippets.

@qexat
Last active August 28, 2023 21:55
Show Gist options
  • Select an option

  • Save qexat/79d0c8a7c667ef9a262ec56e8fb2670e to your computer and use it in GitHub Desktop.

Select an option

Save qexat/79d0c8a7c667ef9a262ec56e8fb2670e to your computer and use it in GitHub Desktop.
become unrunnable. 💪️💪️💪️💪️
import os
import sys
# Printing? No.
del sys.stdout
# Really, no.
del sys.__stdout__
# Errors? "uhhhh object address: [...] lost sys.stderr"
del sys.stderr
# Recovery of stderr: no
del sys.__stderr__
# avoid RuntimeError due to dictionary changing size during iteration
_modules = sys.modules.copy()
# Make it impossible to import
for name, module in _modules.items():
del sys.modules[name]
# Deleting our copy of the modules, hopefully it will get GC'd
del _modules
# Make the import impossibility error even more confusing
del sys.modules
# Carefully deleting what we have imported :P
del sys
# This does not delete System32 don't worry
del os
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment