Message 276506 - Python tracker (original) (raw)
Paul Moore pointed out on distutils-sig that since this is mainly desired for the REPL, we can put the logic in the default excepthook rather than into the SyntaxError constructor the way we had to for "print" and "exec":
def excepthook(typ, value, traceback):
if typ is SyntaxError and "pip install" in value.text:
print("'pip install' found in supplied text")
print("Try running this from a system command prompt")
return
sys.__excepthook__(typ, value, traceback)