summaryrefslogtreecommitdiffstats
path: root/Doc/library/contextlib.rst
Commit message (Collapse)AuthorAgeFilesLines
* gh-93675: Fix typos in `Doc/` (GH-93676)luzpaz2022-06-211-1/+1
| | | Closes #93675
* gh-92082: contextlib docs: Change aclosing from a class to a function for ↵Thaddeus14992022-05-021-1/+1
| | | | | consistency (#92155) Signed-off-by: prwatson <prwatson@redhat.com>
* bpo-28516: document contextlib.ExitStack.__enter__ behavior (GH-31636)vidhya2022-03-281-0/+3
| | | | | | The enter_context is updated with following information: 'The :meth:`__enter__` method returns the ExitStack instance, and performs no additional operations.' Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-45568: Actually use @asynccontextmanager in usage example (GH-29151)Zbigniew Siciarz2021-11-251-0/+2
| | | Automerge-Triggered-By: GH:asvetlov
* bpo-25625: [doc] fix async/aync typo (GH-29091)Thomas Grainger2021-10-201-1/+1
|
* bpo-25625: add contextlib.chdir (GH-28271)Filipe Laíns2021-10-191-2/+19
| | | | | | | | Added non parallel-safe :func:`~contextlib.chdir` context manager to change the current working directory and then restore it on exit. Simple wrapper around :func:`~os.chdir`. Signed-off-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* Update URLs in comments and metadata to use HTTPS (GH-27458)Noah Kantrowitz2021-07-301-1/+1
|
* Doc: fix a rst tag. (GH-26965)Julien Palard2021-06-301-6/+6
|
* bpo-44471: Change error type for bad objects in ExitStack.enter_context() ↵Serhiy Storchaka2021-06-291-0/+8
| | | | | | | | | (GH-26820) A TypeError is now raised instead of an AttributeError in ExitStack.enter_context() and AsyncExitStack.enter_async_context() for objects which do not support the context manager or asynchronous context manager protocols correspondingly.
* bpo-44279: revert 'exceptions are raised' back to 'exceptions occur' (GH-26492)Irit Katriel2021-06-041-1/+1
|
* bpo-44279: [doc] reword contextlib.suppress documentation (GH-26428)MapleCCC2021-06-011-2/+3
|
* bpo-41147: [doc] contextlib.redirect_stdout() provides the new stream as ↵Peter Law2021-05-261-3/+4
| | | | context var (GH-21199)
* bpo-40975: [doc] Identify AsyncExitStack.enter_async_context()/aclose() as ↵naglis2021-05-191-2/+2
| | | | coroutine methods (GH-20870)
* Use the zero argument form of super() in examples for Python3 docs. (GH-22314)Andre Delfino2021-04-261-1/+1
|
* bpo-41543: contextlib.nullcontext can fill in for an async context manager ↵Tom Gringauz2020-11-091-0/+18
| | | | | (GH-21870) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
* [docs] fix wrongly named AsyncContextDecorator (GH-23164)kj2020-11-051-3/+5
| | | Also added versionchanged.
* bpo-40816 Add AsyncContextDecorator class (GH-20516)Kazantcev Andrey2020-11-051-0/+62
| | | | Co-authored-by: Yury Selivanov <yury@edgedb.com>
* bpo-41229: Update docs for explicit aclose()-required cases and add ↵Joongi Kim2020-11-021-0/+33
| | | | | | | | | | | | | | | | | | | contextlib.aclosing() method (GH-21545) This is a PR to: * Add `contextlib.aclosing` which ia analogous to `contextlib.closing` but for async-generators with an explicit test case for [bpo-41229]() * Update the docs to describe when we need explicit `aclose()` invocation. which are motivated by the following issues, articles, and examples: * [bpo-41229]() * https://github.com/njsmith/async_generator * https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#cleanup-in-generators-and-async-generators * https://www.python.org/dev/peps/pep-0533/ * https://github.com/achimnol/aiotools/blob/ef7bf0cea7af/src/aiotools/context.py#L152 Particuarly regarding [PEP-533](https://www.python.org/dev/peps/pep-0533/), its acceptance (`__aiterclose__()`) would make this little addition of `contextlib.aclosing()` unnecessary for most use cases, but until then this could serve as a good counterpart and analogy to `contextlib.closing()`. The same applies for `contextlib.closing` with `__iterclose__()`. Also, still there are other use cases, e.g., when working with non-generator objects with `aclose()` methods.
* [3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)Serhiy Storchaka2019-06-051-2/+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-1/+1
|
* bpo-35506: Remove redundant and incorrect links from keywords. (GH-11174)Serhiy Storchaka2018-12-191-7/+7
|
* Clarify that AsyncExitStack works with coroutine functions (GH-9405)Nathaniel J. Smith2018-09-181-2/+2
| | | | | | | | | | | | The docs were ambiguous about whether you pass in a coroutine function or a coroutine object, e.g. is it: aestack.push_async_exit(some_async_func) or aestack.push_async_exit(some_async_func()) (It's the first one.)
* Fixed typo with asynccontextmanager code example (GH-8845)Alexander Vasin2018-08-251-1/+1
| | | `yield conn`, instead of just `yield`.
* bpo-33468: Add try-finally contextlib.contextmanager example (GH-7816)Matthias Bussonnier2018-07-231-11/+17
|
* bpo-34067: Include a more easily understood example for nullcontext (GH-8158)Daniel Porteous2018-07-091-1/+13
| | | Include a more easily understood example for nullcontext
* bpo-29302: Implement contextlib.AsyncExitStack. (#4790)Ilya Kulakov2018-01-251-0/+38
|
* bpo-30241: implement contextlib.AbstractAsyncContextManager (#1412)Jelle Zijlstra2017-12-141-0/+11
|
* bpo-10049: Add a "no-op" (null) context manager to contextlib (GH-4464)Jesse-Bakker2017-11-231-18/+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-29679: Implement @contextlib.asynccontextmanager (#360)Jelle Zijlstra2017-05-011-0/+30
|
* Closes #27904: Improved logging statements to defer formatting until needed.Vinay Sajip2016-08-311-2/+2
|
* Add a missing :term:.Brett Cannon2016-06-091-1/+1
|
* Issue #23921: Standardized documentation whitespace formatting.Serhiy Storchaka2016-05-101-1/+1
|\ | | | | | | Original patch by James Edwards.
| * Issue #23921: Standardized documentation whitespace formatting.Serhiy Storchaka2016-05-101-1/+1
| | | | | | | | Original patch by James Edwards.
* | Issue #25609: Introduce contextlib.AbstractContextManager andBrett Cannon2016-04-081-2/+14
|/ | | | typing.ContextManager.
* Remove redundant leading zeroes in PEP references.Serhiy Storchaka2016-03-311-1/+1
|
* Issue #25523: Merge a-to-an corrections from 3.4.Serhiy Storchaka2015-11-021-1/+1
|\
| * Issue #25523: Further a-to-an corrections.Serhiy Storchaka2015-11-021-1/+1
| |
* | Issue #25161: Merge full stops from 3.4 into 3.5Martin Panter2015-10-101-1/+1
|\ \ | |/
| * Issue #25161: Add full stops in documentation; patch by Takase ArihiroMartin Panter2015-10-101-1/+1
| |
* | Issue #22389: Add contextlib.redirect_stderr().Berker Peksag2014-11-281-0/+10
|/
* Issue #21061: correctly note redirect_stdout is reentrantNick Coghlan2014-10-121-1/+1
|
* Issue 22603: add missing 'self'. Patch by Francisco Fernández Castaño.Terry Jan Reedy2014-10-101-2/+2
|
* Issue 21558: Fix a typo in the contextlib docsRaymond Hettinger2014-05-261-1/+1
|
* Close #19403: make contextlib.redirect_stdout reentrantNick Coghlan2013-11-031-40/+77
|
* What's New updates prior to alphaNick Coghlan2013-10-201-2/+3
|
* contextlib doc updates and refactoringNick Coghlan2013-10-191-0/+116
| | | | | | | | | | | - 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-8/+18
| | | | Patch by Zero Piraeus.
* Fix spacing of toplevel items.Georg Brandl2013-10-131-0/+2
|
* Docs tweaks for contextlib additionsNick Coghlan2013-10-131-2/+12
|
* Rename contextlib.ignored() to contextlib.ignore().Raymond Hettinger2013-10-111-3/+3
|