mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Deprecate contextlib.nested(). The with-statement now provides this functionality directly.
This commit is contained in:
parent
b4d2d31874
commit
822b87f276
4 changed files with 11 additions and 2 deletions
|
@ -83,6 +83,8 @@ Functions provided:
|
|||
:meth:`__exit__` methods should avoid raising exceptions, and in particular they
|
||||
should not re-raise a passed-in exception.
|
||||
|
||||
.. deprecated:: 2.7
|
||||
The with-statement now supports this functionality directly.
|
||||
|
||||
.. function:: closing(thing)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import sys
|
||||
from functools import wraps
|
||||
from warnings import warn
|
||||
|
||||
__all__ = ["contextmanager", "nested", "closing"]
|
||||
|
||||
|
@ -101,6 +102,8 @@ def nested(*managers):
|
|||
<body>
|
||||
|
||||
"""
|
||||
warn("With-statements now directly support multiple context managers",
|
||||
DeprecationWarning, 2)
|
||||
exits = []
|
||||
vars = []
|
||||
exc = (None, None, None)
|
||||
|
|
|
@ -9,6 +9,7 @@ import unittest
|
|||
import threading
|
||||
from contextlib import * # Tests __all__
|
||||
from test import test_support
|
||||
import warnings
|
||||
|
||||
class ContextManagerTestCase(unittest.TestCase):
|
||||
|
||||
|
@ -331,6 +332,8 @@ class LockContextTestCase(unittest.TestCase):
|
|||
|
||||
# This is needed to make the test actually run under regrtest.py!
|
||||
def test_main():
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
test_support.run_unittest(__name__)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -12,7 +12,8 @@ What's New in Python 2.7 alpha 1
|
|||
Core and Builtins
|
||||
-----------------
|
||||
|
||||
- Added support for multiple context managers in the same with statement.
|
||||
- Added support for multiple context managers in the same with-statement.
|
||||
Deprecated contextlib.nested() which is no longer needed.
|
||||
|
||||
- Issue #6101: A new opcode, SETUP_WITH, has been added to speed up the with
|
||||
statement and correctly lookup the __enter__ and __exit__ special methods.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue