[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread Tal Einat
Tal Einat added the comment: Thanks for the PR, Matthias Bussonnier! -- nosy: +mbussonn resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 2.7 ___ Python tracker

[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread Tal Einat
Tal Einat added the comment: New changeset 4e166ffd29b675238ccd94964743f6cb206d2235 by Tal Einat (Miss Islington (bot)) in branch '3.7': bpo-33468: Add try-finally contextlib.contextmanager example (GH-7816) (GH-8425)

[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread Tal Einat
Tal Einat added the comment: New changeset 5b3643d1a5114551350a9d17fb0aaab2d503c290 by Tal Einat (Miss Islington (bot)) in branch '3.6': bpo-33468: Add try-finally contextlib.contextmanager example (GH-7816) (GH-8426)

[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread Tal Einat
Tal Einat added the comment: New changeset f7e60a69485097dc28f000c55615038278f84333 by Tal Einat in branch '2.7': [2.7] bpo-33468: Add try-finally contextlib.contextmanager example (GH-7816) (GH-8427) https://github.com/python/cpython/commit/f7e60a69485097dc28f000c55615038278f84333

[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread Tal Einat
Change by Tal Einat : -- pull_requests: +7953 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread miss-islington
Change by miss-islington : -- pull_requests: +7952 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread Tal Einat
Tal Einat added the comment: New changeset bde782bb594edffeabe978abeee2b7082ab9bc2a by Tal Einat (Matthias Bussonnier) in branch 'master': bpo-33468: Add try-finally contextlib.contextmanager example (GH-7816) https://github.com/python/cpython/commit/bde782bb594edffeabe978abeee2b7082ab9bc2a

[issue33468] Add try-finally contextlib.contextmanager example

2018-07-23 Thread miss-islington
Change by miss-islington : -- pull_requests: +7951 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33468] Add try-finally contextlib.contextmanager example

2018-06-30 Thread Tal Einat
Tal Einat added the comment: Nick's abstract example LGTM as well. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue33468] Add try-finally contextlib.contextmanager example

2018-06-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The entirely abstract example LGTM. As for concrete real word examples, the possible one is changing the current working directory: cwd = os.getcwd() try: os.chdir(target_dir) yield finally: os.chdir(cwd) --

[issue33468] Add try-finally contextlib.contextmanager example

2018-06-24 Thread Nick Coghlan
Nick Coghlan added the comment: Similar to closing, we have dedicated context managers for stdout and stderr redirection now: https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout Redirecting stdin could be a good example though, since we've so far chosen not to

[issue33468] Add try-finally contextlib.contextmanager example

2018-06-24 Thread Tal Einat
Tal Einat added the comment: A possible concrete example: Capturing sys.stdout and/or sys.stderr for testing, as in test.support.captured_output. -- nosy: +taleinat ___ Python tracker

[issue33468] Add try-finally contextlib.contextmanager example

2018-06-20 Thread Nick Coghlan
Nick Coghlan added the comment: Right, the HTML example was always a bit cutesy (hence the disclaimer in the header), but it's hard to come up with a good illustrative example that isn't already a native context manager in the standard library. Perhaps it would make sense to change the

[issue33468] Add try-finally contextlib.contextmanager example

2018-06-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It doesn't look as a good example. It is not always good to write a closing tag if an error was occurred while write an inner content. In many cases it is better to stop writing after error. -- nosy: +serhiy.storchaka

[issue33468] Add try-finally contextlib.contextmanager example

2018-06-20 Thread Matthias Bussonnier
Change by Matthias Bussonnier : -- keywords: +patch pull_requests: +7424 stage: needs patch -> patch review ___ Python tracker ___

[issue33468] Add try-finally contextlib.contextmanager example

2018-05-20 Thread Petr Viktorin
Change by Petr Viktorin : -- nosy: +petr.viktorin ___ Python tracker ___ ___

[issue33468] Add try-finally contextlib.contextmanager example

2018-05-11 Thread Nick Coghlan
New submission from Nick Coghlan : The current example for contextlib.contextmanager doesn't use try/finally, which sets folks up for writing resource management context managers that don't clean up after exceptions properly. There's an example with try/finally down in the