mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Close #19266: contextlib.ignore -> contextlib.suppress
Patch by Zero Piraeus.
This commit is contained in:
parent
1eb509a585
commit
240f86d7dd
6 changed files with 58 additions and 39 deletions
|
@ -5,7 +5,7 @@ from collections import deque
|
|||
from functools import wraps
|
||||
|
||||
__all__ = ["contextmanager", "closing", "ContextDecorator", "ExitStack",
|
||||
"ignore", "redirect_stdout"]
|
||||
"redirect_stdout", "suppress"]
|
||||
|
||||
|
||||
class ContextDecorator(object):
|
||||
|
@ -179,10 +179,10 @@ class redirect_stdout:
|
|||
sys.stdout = self.old_target
|
||||
|
||||
@contextmanager
|
||||
def ignore(*exceptions):
|
||||
"""Context manager to ignore specified exceptions
|
||||
def suppress(*exceptions):
|
||||
"""Context manager to suppress specified exceptions
|
||||
|
||||
with ignore(OSError):
|
||||
with suppress(OSError):
|
||||
os.remove(somefile)
|
||||
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue