Last active
November 6, 2018 16:20
-
-
Save sirosen/791bf1a692ceaad8f73100a7e139ce09 to your computer and use it in GitHub Desktop.
reproduce click #1134
This file contains 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
$ python test.py | |
in dummy_transaction pre-yield | |
going critical | |
in dummy_transaction except clause |
This file contains 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
#!/usr/bin/env python3 | |
from contextlib import ExitStack, contextmanager | |
import click | |
@contextmanager | |
def dummy_transaction(): | |
try: | |
print('in dummy_transaction pre-yield') | |
yield | |
print('in dummy_transaction post-yield') | |
except: | |
print('in dummy_transaction except clause') | |
raise | |
else: | |
print('in dummy_transaction else clause') | |
@click.command() | |
def main(): | |
with ExitStack() as uh_wut: | |
uh_wut.enter_context(dummy_transaction()) | |
print('going critical') | |
raise click.exceptions.Exit(0) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment