aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_contextlib.py
Commit message (Collapse)AuthorAge
* gh-95882: fix regression in the traceback of exceptions propagated from ↵Thomas Grainger2023-01-03
| | | | inside a contextlib context manager (#95883)
* gh-92118: Add test for traceback when exception is modified by ↵Irit Katriel2022-05-05
| | | | (Async)ExitStack.__exit__ (GH-92339)
* gh-92118: fix traceback of exceptions propagated from inside a ↵Irit Katriel2022-05-04
| | | | contextlib.contextmanager (GH-92202)
* bpo-46425: Fix direct invocation of `test_contextlib` (GH-30681)Nikita Sobolev2022-01-21
|
* bpo-25625: add contextlib.chdir (GH-28271)Filipe Laíns2021-10-20
| | | | | | | | 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>
* bpo-44594: fix (Async)ExitStack handling of __context__ (gh-27089)John Belmonte2021-10-03
| | | | | | | | | * bpo-44594: fix (Async)ExitStack handling of __context__ Make enter_context(foo()) / enter_async_context(foo()) equivalent to `[async] with foo()` regarding __context__ when an exception is raised. Previously exceptions would be caught and re-raised with the wrong context when explicitly overriding __context__ with None.
* bpo-44515: handle non-refcounted GC in contextlib tests (GH-26910)Nick Coghlan2021-07-26
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-44566: resolve differences between asynccontextmanager and ↵Thomas Grainger2021-07-20
| | | | contextmanager (#27024)
* bpo-44471: Change error type for bad objects in ExitStack.enter_context() ↵Serhiy Storchaka2021-06-29
| | | | | | | | | (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-12022: Change error type for bad objects in "with" and "async with" ↵Serhiy Storchaka2021-06-29
| | | | | | | | | (GH-26809) A TypeError is now raised instead of an AttributeError in "with" and "async with" statements for objects which do not support the context manager or asynchronous context manager protocols correspondingly.
* bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145)Inada Naoki2021-04-04
| | | | | | | | | | | | | | | | | | | * test_asyncio * test_bz2 * test_math * test_cmath * test_cmd_line * test_cmd_line_script * test_compile * test_contextlib * test_profile * ctypes/test/test_find * test_multiprocessing * test_configparser * test_csv * test_dbm_dumb * test_decimal * test_difflib * os.fdopen() calls io.text_encoding() to emit EncodingWarning for right place.
* bpo-40275: Use new test.support helper submodules in tests (GH-21412)Hai Shi2020-07-09
|
* [3.9] bpo-37116: Use PEP 570 syntax for positional-only parameters. (GH-12620)Serhiy Storchaka2019-06-05
| | | Turn deprecation warnings added in 3.8 into TypeError.
* bpo-36492: Deprecate passing some arguments as keyword arguments. (GH-12637)Serhiy Storchaka2019-04-01
| | | | | | | | | | | | | | | | | | | | | | 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-35202: Remove unused imports in Lib directory (GH-10450)Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి)2018-11-15
|
* bpo-30306: release arguments of contextmanager (GH-1500)Martin Teichmann2018-01-28
| | | | | | | | | | | | | | | | 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-25
|
* bpo-10049: Add a "no-op" (null) context manager to contextlib (GH-4464)Jesse-Bakker2017-11-23
| | | | | 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-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-07
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-30266: support "= None" pattern in AbstractContextManager (#1448)Jelle Zijlstra2017-06-09
| | | | | contextlib.AbstractContextManager now supports anti-registration by setting __enter__ = None or __exit__ = None, following the pattern introduced in bpo-25958.
* bpo-29692: contextlib.contextmanager may incorrectly unchain RuntimeError ↵svelankar2017-04-11
| | | | | | | | | | (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.
* Added more tests for issue #27122.Serhiy Storchaka2016-06-20
|\
| * Added more tests for issue #27122.Serhiy Storchaka2016-06-20
| |
* | Issue #27123: When an exception is raised within the context beingGregory P. Smith2016-06-14
|\| | | | | | | | | | | | | 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-14
| | | | | | | | | | | | | | 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 #25609: Introduce contextlib.AbstractContextManager andBrett Cannon2016-04-08
| | | | | | | | typing.ContextManager.
* | Issue #26136: Upgrade the generator_stop warning to DeprecationWarningMartin Panter2016-02-10
|/ | | | Patch by Anish Shah.
* Issue #25322: Merge contextlib.suppress test fix from 3.4 into 3.5Martin Panter2015-10-10
|\
| * Issue #25322: Fix test for nested contextlib.suppressMartin Panter2015-10-10
| |
* | Issue #24336: The contextmanager decorator now works with functions withSerhiy Storchaka2015-06-28
|\| | | | | | | keyword arguments called "func" and "self". Patch by Martin Panter.
| * Issue #24336: The contextmanager decorator now works with functions withSerhiy Storchaka2015-06-28
| | | | | | | | keyword arguments called "func" and "self". Patch by Martin Panter.
* | Issue 24237: Raise PendingDeprecationWarning per PEP 479Yury Selivanov2015-05-22
| | | | | | | | | | | | | | | | | | Raise PendingDeprecationWarning when generator raises StopIteration and no __future__ import is used. Fix offenders in the stdlib and tests. See also issue 22906. Thanks to Nick Coghlan and Berker Peksag for reviews.
* | PEP 479: Change StopIteration handling inside generators.Yury Selivanov2015-05-09
| | | | | | | | Closes issue #22906.
* | Issue #22389: Add contextlib.redirect_stderr().Berker Peksag2014-11-28
|/
* Merge removal of issue 20317 debugging code from 3.3Nick Coghlan2014-01-24
|\
| * Issue 20317: Remove debugging code from contextlibNick Coghlan2014-01-24
| | | | | | | | | | | | | | - 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-22
|\|
| * Issue #20317: Don't create a reference loop in ExitStackNick Coghlan2014-01-22
| |
* | Close #19403: make contextlib.redirect_stdout reentrantNick Coghlan2013-11-03
| |
* | Issue #19330: Handle the no-docstrings case in testsNick Coghlan2013-10-26
| |
* | Close #19330 by using public classes in contextlibNick Coghlan2013-10-26
| | | | | | | | | | | | | | - 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
* | Close #19396: make test_contextlib tolerate -SNick Coghlan2013-10-26
| |
* | contextlib doc updates and refactoringNick Coghlan2013-10-20
| | | | | | | | | | | | | | | | | | | | | | - 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-17
| | | | | | | | Patch by Zero Piraeus.
* | Rename contextlib.ignored() to contextlib.ignore().Raymond Hettinger2013-10-10
| |
* | Issue #15805: Add contextlib.redirect_stdout()Raymond Hettinger2013-10-10
| |
* | Merge #19092 from 3.3Nick Coghlan2013-10-01
|\|
| * Close #19092: ExitStack now reraises exceptions from __exit__Nick Coghlan2013-10-01
| | | | | | | | Report and patch by Hrvoje Nikšić
* | Update various test modules to use unittest.main() for test discoveryBrett Cannon2013-06-12
| | | | | | | | instead of manually listing tests for test.support.run_unittest().
* | Issue #15806: Add contextlib.ignored().Raymond Hettinger2013-03-10
|/