Skip to content

Instantly share code, notes, and snippets.

@sirosen
Last active November 6, 2018 16:20
Show Gist options
  • Save sirosen/791bf1a692ceaad8f73100a7e139ce09 to your computer and use it in GitHub Desktop.
Save sirosen/791bf1a692ceaad8f73100a7e139ce09 to your computer and use it in GitHub Desktop.
reproduce click #1134
$ python test.py
in dummy_transaction pre-yield
going critical
in dummy_transaction except clause
#!/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