From 67b212e608044b094272248200db71af69518df9 Mon Sep 17 00:00:00 2001 From: Antoine Pitrou Date: Sat, 8 Jan 2011 09:55:31 +0000 Subject: Issue #10859: Make `contextlib.GeneratorContextManager` officially private by renaming it to `_GeneratorContextManager`. --- Lib/contextlib.py | 4 ++-- Lib/test/test_with.py | 12 ++++++------ Misc/NEWS | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Lib/contextlib.py b/Lib/contextlib.py index e37fde8..4633cff 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -17,7 +17,7 @@ class ContextDecorator(object): return inner -class GeneratorContextManager(ContextDecorator): +class _GeneratorContextManager(ContextDecorator): """Helper for @contextmanager decorator.""" def __init__(self, gen): @@ -92,7 +92,7 @@ def contextmanager(func): """ @wraps(func) def helper(*args, **kwds): - return GeneratorContextManager(func(*args, **kwds)) + return _GeneratorContextManager(func(*args, **kwds)) return helper diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py index d6308e4..a9d374b 100644 --- a/Lib/test/test_with.py +++ b/Lib/test/test_with.py @@ -9,26 +9,26 @@ __email__ = "mbland at acm dot org" import sys import unittest from collections import deque -from contextlib import GeneratorContextManager, contextmanager +from contextlib import _GeneratorContextManager, contextmanager from test.support import run_unittest -class MockContextManager(GeneratorContextManager): +class MockContextManager(_GeneratorContextManager): def __init__(self, gen): - GeneratorContextManager.__init__(self, gen) + _GeneratorContextManager.__init__(self, gen) self.enter_called = False self.exit_called = False self.exit_args = None def __enter__(self): self.enter_called = True - return GeneratorContextManager.__enter__(self) + return _GeneratorContextManager.__enter__(self) def __exit__(self, type, value, traceback): self.exit_called = True self.exit_args = (type, value, traceback) - return GeneratorContextManager.__exit__(self, type, - value, traceback) + return _GeneratorContextManager.__exit__(self, type, + value, traceback) def mock_contextmanager(func): diff --git a/Misc/NEWS b/Misc/NEWS index 0683245..0b2d346 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -40,6 +40,9 @@ Core and Builtins Library ------- +- Issue #10859: Make ``contextlib.GeneratorContextManager`` officially + private by renaming it to ``_GeneratorContextManager``. + - Issue #10042: Fixed the total_ordering decorator to handle cross-type comparisons that could lead to infinite recursion. -- cgit v0.12