Created
February 1, 2016 02:07
-
-
Save suzaku/cc77dd554d73f866f085 to your computer and use it in GitHub Desktop.
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 | |
class Stupid(Exception): | |
pass | |
class X: | |
def __getattr__(self, name): | |
print("You won't get %s" % name) | |
return Stupid | |
x = X() | |
def test(err=None): | |
try: | |
if err: | |
raise err | |
except ValueError: | |
print('what?') | |
except x.LazyEval as e: | |
print(e) | |
except sys.not_exist_at_all: | |
pass | |
if __name__ == '__main__': | |
error = sys.argv[1] if len(sys.argv) > 1 else None | |
if error == 'value': | |
error = ValueError | |
elif error == 'type': | |
error = Stupid | |
elif error == 'other': | |
error = OSError | |
test(error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment