mirror of
https://github.com/jazzband/contextlib2.git
synced 2026-04-03 22:40:30 +00:00
Add back ContextStack alias
This commit is contained in:
parent
6a40a1ee80
commit
630f73a3a5
1 changed files with 19 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue