@@ -95,29 +95,39 @@ Functions and classes provided:
9595 ``page.close() `` will be called when the :keyword: `with ` block is exited.
9696
9797
98- .. function :: ignore (*exceptions)
98+ .. function :: suppress (*exceptions)
9999
100- Return a context manager that ignores the specified exceptions if they
101- occur in the body of a with-statement.
100+ Return a context manager that suppresses any of the specified exceptions
101+ if they occur in the body of a with statement and then resumes execution
102+ with the first statement following the end of the with statement.
102103
103- As with any other mechanism that completely suppresses exceptions, it
104- should only be used to cover very specific errors where silently
105- ignoring the exception is known to be the right thing to do.
104+ As with any other mechanism that completely suppresses exceptions, this
105+ context manager should be used only to cover very specific errors where
106+ silently continuing with program execution is known to be the right
107+ thing to do.
106108
107109 For example::
108110
109- from contextlib import ignore
111+ from contextlib import suppress
110112
111- with ignore (FileNotFoundError):
113+ with suppress (FileNotFoundError):
112114 os.remove('somefile.tmp')
113115
116+ with suppress(FileNotFoundError):
117+ os.remove('someotherfile.tmp')
118+
114119 This code is equivalent to::
115120
116121 try:
117122 os.remove('somefile.tmp')
118123 except FileNotFoundError:
119124 pass
120125
126+ try:
127+ os.remove('someotherfile.tmp')
128+ except FileNotFoundError:
129+ pass
130+
121131 .. versionadded :: 3.4
122132
123133
0 commit comments