Add back ContextStack alias

This commit is contained in:
Nick Coghlan 2021-06-26 16:50:39 +10:00
parent 6a40a1ee80
commit 630f73a3a5

View file

@ -767,3 +767,22 @@ class nullcontext(AbstractContextManager, AbstractAsyncContextManager):
async def __aexit__(self, *excinfo):
pass
# Preserve backwards compatibility
class ContextStack(ExitStack):
"""Backwards compatibility alias for ExitStack"""
def __init__(self):
warnings.warn("ContextStack has been renamed to ExitStack",
DeprecationWarning)
super(ContextStack, self).__init__()
def register_exit(self, callback):
return self.push(callback)
def register(self, callback, *args, **kwds):
return self.callback(callback, *args, **kwds)
def preserve(self):
return self.pop_all()