summaryrefslogtreecommitdiffstats
path: root/Lib/contextlib.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)Serhiy Storchaka2019-06-051-34/+2
| | | Turn deprecation warnings added in 3.8 into TypeError.
* bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-13700)Serhiy Storchaka2019-06-011-4/+2
|
* bpo-36542: Allow to overwrite the signature for Python functions. (GH-12705)Serhiy Storchaka2019-05-061-0/+2
|
* bpo-36492: Deprecate passing some arguments as keyword arguments. (GH-12637)Serhiy Storchaka2019-04-011-4/+36
| | | | | | | | | | | | | | | | | | | | | | Deprecated passing the following arguments as keyword arguments: - "func" in functools.partialmethod(), weakref.finalize(), profile.Profile.runcall(), cProfile.Profile.runcall(), bdb.Bdb.runcall(), trace.Trace.runfunc() and curses.wrapper(). - "function" in unittest.addModuleCleanup() and unittest.TestCase.addCleanup(). - "fn" in the submit() method of concurrent.futures.ThreadPoolExecutor and concurrent.futures.ProcessPoolExecutor. - "callback" in contextlib.ExitStack.callback(), contextlib.AsyncExitStack.callback() and contextlib.AsyncExitStack.push_async_callback(). - "c" and "typeid" in the create() method of multiprocessing.managers.Server and multiprocessing.managers.SharedMemoryServer. - "obj" in weakref.finalize(). Also allowed to pass arbitrary keyword arguments (even "self" and "func") if the above arguments are passed as positional argument.
* bpo-33786: Fix asynchronous generators to handle GeneratorExit in athrow() ↵Yury Selivanov2018-06-081-1/+1
| | | | (GH-7467)
* bpo-33265: use an actual method instead of a method-like function in ↵jdemeyer2018-04-131-8/+3
| | | | | | ExitStack (GH-6456) `MethodType` has the exact semantics that `ExitStack` needs, so we can avoid creating a Python level closure.
* bpo-30306: release arguments of contextmanager (GH-1500)Martin Teichmann2018-01-281-0/+3
| | | | | | | | | | | | | | | | The arguments to a generator function which is declared as a contextmanager are stored inside the context manager, and thus are kept alive, even when it is used as a regular context manager, and not as a function decorator (where it needs the original arguments to recreate the generator on each call). This is a possible unnecessary memory leak, so this changes contextmanager.__enter__ to release the saved arguments, as that method being called means that particular CM instance isn't going to need to recreate the underlying generator. Patch by Martin Teichmann.
* bpo-29302: Implement contextlib.AsyncExitStack. (#4790)Ilya Kulakov2018-01-251-46/+205
|
* bpo-30241: implement contextlib.AbstractAsyncContextManager (#1412)Jelle Zijlstra2017-12-141-2/+25
|
* bpo-10049: Add a "no-op" (null) context manager to contextlib (GH-4464)Jesse-Bakker2017-11-231-1/+22
| | | | | Adds a simpler and faster alternative to ExitStack for handling single optional context managers without having to change the lexical structure of your code.
* bpo-30266: support "= None" pattern in AbstractContextManager (#1448)Jelle Zijlstra2017-06-091-3/+2
| | | | | contextlib.AbstractContextManager now supports anti-registration by setting __enter__ = None or __exit__ = None, following the pattern introduced in bpo-25958.
* bpo-29679: Implement @contextlib.asynccontextmanager (#360)Jelle Zijlstra2017-05-011-6/+93
|
* bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError ↵svelankar2017-04-111-6/+6
| | | | | | | | | | (GH-949) contextlib._GeneratorContextManager.__exit__ includes a special case to deal with PEP 479 RuntimeErrors created when `StopIteration` is thrown into the context manager body. Previously this check was too permissive, and undid one level of chaining on *all* RuntimeError instances, not just those that wrapped a StopIteration instance.
* Clarify exception handler scope in contextlibamosonn2017-03-011-1/+2
| | | Moved explicit raise from inside try to try...else.
* bpo-27122: Fix comment to point to correct issue number (#47)Nathaniel J. Smith2017-02-121-1/+1
| | | | | | It took me quite a bit to figure out what this was referring to, since the given issue number is wrong, and the original commit message I found through git blame lists a different, also wrong issue number... see https://bugs.python.org/issue27122#msg279449
* Issue #27123: When an exception is raised within the context beingGregory P. Smith2016-06-141-0/+3
|\ | | | | | | | | | | | | managed by a contextlib.ExitStack() and one of the exit stack generators catches and raises it in a chain, do not re-raise the original exception when exiting, let the new chained one through. This avoids the PEP 479 bug described in issue25782.
| * Issue #27123: When an exception is raised within the context beingGregory P. Smith2016-06-141-0/+3
| | | | | | | | | | | | | | managed by a contextlib.ExitStack() and one of the exit stack generators catches and raises it in a chain, do not re-raise the original exception when exiting, let the new chained one through. This avoids the PEP 479 bug described in issue25782.
* | Normalize whitespaceBrett Cannon2016-04-081-1/+1
| |
* | Issue #25609: Introduce contextlib.AbstractContextManager andBrett Cannon2016-04-081-11/+31
|/ | | | typing.ContextManager.
* Issue #24336: The contextmanager decorator now works with functions withSerhiy Storchaka2015-06-281-3/+3
|\ | | | | | | keyword arguments called "func" and "self". Patch by Martin Panter.
| * Issue #24336: The contextmanager decorator now works with functions withSerhiy Storchaka2015-06-281-3/+3
| | | | | | | | keyword arguments called "func" and "self". Patch by Martin Panter.
* | PEP 479: Change StopIteration handling inside generators.Yury Selivanov2015-05-091-2/+9
| | | | | | | | Closes issue #22906.
* | Issue #22389: Add contextlib.redirect_stderr().Berker Peksag2014-11-281-13/+27
|/
* Merge removal of issue 20317 debugging code from 3.3Nick Coghlan2014-01-241-3/+1
|\
| * Issue 20317: Remove debugging code from contextlibNick Coghlan2014-01-241-3/+1
| | | | | | | | | | | | | | - Alex J Burke noticed a debugging raise in the commit that fixed the original bug reported in issue 20317 - this showed that multiple iterations through the affected loop wasn't actually being tested
* | Merge #20317 from 3.3Nick Coghlan2014-01-221-1/+9
|\ \ | |/
| * Issue #20317: Don't create a reference loop in ExitStackNick Coghlan2014-01-221-1/+9
| |
* | Close #19403: make contextlib.redirect_stdout reentrantNick Coghlan2013-11-031-8/+4
| |
* | Close #19330 by using public classes in contextlibNick Coghlan2013-10-261-41/+39
| | | | | | | | | | | | | | - added test cases to ensure docstrings are reasonable - also updates various comments in contextlib for accuracy - identifed #19404 as an issue making it difficult to provide good help output on generator based context manager instances
* | contextlib doc updates and refactoringNick Coghlan2013-10-191-29/+52
| | | | | | | | | | | | | | | | | | | | | | - explain single use, reusable and reentrant in docs - converted suppress to a reentrant class based impl - converted redirect_stdout to a reusable impl - moved both suppress and redirect_stdout behind a functional facade - added reentrancy tests for the updated suppress - added reusability tests for the updated redirect_stdio - slightly cleaned up an exception from contextmanager
* | Close #19266: contextlib.ignore -> contextlib.suppressNick Coghlan2013-10-171-4/+4
| | | | | | | | Patch by Zero Piraeus.
* | Rename contextlib.ignored() to contextlib.ignore().Raymond Hettinger2013-10-111-3/+3
| |
* | Issue #15805: Add contextlib.redirect_stdout()Raymond Hettinger2013-10-101-1/+39
| |
* | Merge #19092 from 3.3Nick Coghlan2013-10-011-3/+15
|\ \ | |/
| * Close #19092: ExitStack now reraises exceptions from __exit__Nick Coghlan2013-10-011-3/+15
| | | | | | | | Report and patch by Hrvoje Nikšić
* | #18705: merge with 3.3.Ezio Melotti2013-08-171-1/+1
|\ \ | |/
* | Issue #15806: Add contextlib.ignored().Raymond Hettinger2013-03-111-1/+13
|/
* Issue #16714: use 'raise' exceptions, don't 'throw'.Andrew Svetlov2012-12-181-1/+1
|\ | | | | | | Patch by Serhiy Storchaka.
* | Close #14969: Improve the handling of exception chaining in contextlib.ExitStackNick Coghlan2012-06-011-3/+13
| |
* | Close #14963: Use an iterative algorithm in contextlib.ExitStack.__exit__ ↵Nick Coghlan2012-05-311-26/+15
| | | | | | | | (Patch by Alon Horev)
* | Close #13585: add contextlib.ExitStack to replace the ill-fated ↵Nick Coghlan2012-05-211-5/+121
| | | | | | | | contextlib.nested API
* | remove unused imports (closes #12432)Benjamin Peterson2011-06-281-1/+0
|/ | | | A patch from Vincent Legoll.
* Remove trailing whitespaceNick Coghlan2011-05-051-2/+2
|
* Issue #11647: allow contextmanager objects to be used as decorators as ↵Nick Coghlan2011-05-051-4/+24
| | | | described in the docs. Initial patch by Ysj Ray.
* Issue #10859: Make `contextlib.GeneratorContextManager` officiallyAntoine Pitrou2011-01-081-2/+2
| | | | private by renaming it to `_GeneratorContextManager`.
* Issue 9110. Adding ContextDecorator to contextlib. This enables the creation ↵Michael Foord2010-06-301-2/+13
| | | | of APIs that act as decorators as well as context managers. contextlib.contextmanager changed to use ContextDecorator.
* remove nested from __all__Benjamin Peterson2009-07-011-1/+1
|
* Removed contextlib.nested()Raymond Hettinger2009-07-011-45/+0
|
* Merged revisions 73518-73519 via svnmerge fromNick Coghlan2009-06-231-10/+8
| | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r73518 | nick.coghlan | 2009-06-23 20:19:30 +1000 (Tue, 23 Jun 2009) | 1 line Issue 6288: Update contextlib.nested() docstring to reflect new documentation ........ r73519 | nick.coghlan | 2009-06-23 20:51:02 +1000 (Tue, 23 Jun 2009) | 1 line Remove markup from docstring ........
* Issue 6256: Fix stacklevel in warning message.Raymond Hettinger2009-06-101-1/+1
|