[Python-checkins] cpython (3.5): Issue #25609: Backport typing.ContextManager.

brett.cannon python-checkins at python.org
Fri Apr 15 13:51:50 EDT 2016


https://hg.python.org/cpython/rev/257dd57dd732
changeset: 100986:257dd57dd732
branch: 3.5
parent: 100983:8dee0c09b46e
user: Brett Cannon <brett at python.org>
date: Fri Apr 15 10:51:30 2016 -0700
summary:
 Issue #25609: Backport typing.ContextManager.
This has no semantic impact as the class is guarded with a hasattr()
check; this is being done to keep typing.py in sync between Python 3.5
and 3.6 as requested by Guido.
files:
 Lib/typing.py | 7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/Lib/typing.py b/Lib/typing.py
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1,6 +1,7 @@
 import abc
 from abc import abstractmethod, abstractproperty
 import collections
+import contextlib
 import functools
 import re as stdlib_re # Avoid confusion with the re we export.
 import sys
@@ -1530,6 +1531,12 @@
 pass
 
 
+if hasattr(contextlib, 'AbstractContextManager'):
+ class ContextManager(Generic[T_co], extra=contextlib.AbstractContextManager):
+ __slots__ = ()
+ __all__.append('ContextManager')
+
+
 class Dict(dict, MutableMapping[KT, VT]):
 
 def __new__(cls, *args, **kwds):
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /