Commit 67b212e6 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #10859: Make `contextlib.GeneratorContextManager` officially

private by renaming it to `_GeneratorContextManager`.
parent d97b7b51
...@@ -17,7 +17,7 @@ class ContextDecorator(object): ...@@ -17,7 +17,7 @@ class ContextDecorator(object):
return inner return inner
class GeneratorContextManager(ContextDecorator): class _GeneratorContextManager(ContextDecorator):
"""Helper for @contextmanager decorator.""" """Helper for @contextmanager decorator."""
def __init__(self, gen): def __init__(self, gen):
...@@ -92,7 +92,7 @@ def contextmanager(func): ...@@ -92,7 +92,7 @@ def contextmanager(func):
""" """
@wraps(func) @wraps(func)
def helper(*args, **kwds): def helper(*args, **kwds):
return GeneratorContextManager(func(*args, **kwds)) return _GeneratorContextManager(func(*args, **kwds))
return helper return helper
......
...@@ -9,26 +9,26 @@ __email__ = "mbland at acm dot org" ...@@ -9,26 +9,26 @@ __email__ = "mbland at acm dot org"
import sys import sys
import unittest import unittest
from collections import deque from collections import deque
from contextlib import GeneratorContextManager, contextmanager from contextlib import _GeneratorContextManager, contextmanager
from test.support import run_unittest from test.support import run_unittest
class MockContextManager(GeneratorContextManager): class MockContextManager(_GeneratorContextManager):
def __init__(self, gen): def __init__(self, gen):
GeneratorContextManager.__init__(self, gen) _GeneratorContextManager.__init__(self, gen)
self.enter_called = False self.enter_called = False
self.exit_called = False self.exit_called = False
self.exit_args = None self.exit_args = None
def __enter__(self): def __enter__(self):
self.enter_called = True self.enter_called = True
return GeneratorContextManager.__enter__(self) return _GeneratorContextManager.__enter__(self)
def __exit__(self, type, value, traceback): def __exit__(self, type, value, traceback):
self.exit_called = True self.exit_called = True
self.exit_args = (type, value, traceback) self.exit_args = (type, value, traceback)
return GeneratorContextManager.__exit__(self, type, return _GeneratorContextManager.__exit__(self, type,
value, traceback) value, traceback)
def mock_contextmanager(func): def mock_contextmanager(func):
......
...@@ -40,6 +40,9 @@ Core and Builtins ...@@ -40,6 +40,9 @@ Core and Builtins
Library Library
------- -------
- Issue #10859: Make ``contextlib.GeneratorContextManager`` officially
private by renaming it to ``_GeneratorContextManager``.
- Issue #10042: Fixed the total_ordering decorator to handle cross-type - Issue #10042: Fixed the total_ordering decorator to handle cross-type
comparisons that could lead to infinite recursion. comparisons that could lead to infinite recursion.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment