Skip to content

Instantly share code, notes, and snippets.

@jimbaker
Last active August 16, 2016 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbaker/7f260df8605fb156ae155800a383e357 to your computer and use it in GitHub Desktop.
Save jimbaker/7f260df8605fb156ae155800a383e357 to your computer and use it in GitHub Desktop.
Rebind sys.exit in Jython
$ ~/jython2.7.0/bin/jython
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_75
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> def f(*args):
... print "tried to exit %r" % (args,)
...
>>> sys.exit = f
>>> sys.exit(-1)
tried to exit (-1,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment