| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a76795b commit 1254b40
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -94,16 +94,16 @@ Functions and classes provided: | |||
| 94 | 94 | without needing to explicitly close ``page``. Even if an error occurs, | |
| 95 | 95 | ``page.close()`` will be called when the :keyword:`with` block is exited. | |
| 96 | 96 | ||
| 97 | - .. function:: ignored(*exceptions) | ||
| 97 | + .. function:: ignore(*exceptions) | ||
| 98 | 98 | ||
| 99 | 99 | Return a context manager that ignores the specified exceptions if they | |
| 100 | 100 | occur in the body of a with-statement. | |
| 101 | 101 | ||
| 102 | 102 | For example:: | |
| 103 | 103 | ||
| 104 | - from contextlib import ignored | ||
| 104 | + from contextlib import ignore | ||
| 105 | 105 | ||
| 106 | - with ignored(OSError): | ||
| 106 | + with ignore(OSError): | ||
| 107 | 107 | os.remove('somefile.tmp') | |
| 108 | 108 | ||
| 109 | 109 | This code is equivalent to:: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,7 +5,7 @@ | |||
| 5 | 5 | from functools import wraps | |
| 6 | 6 | ||
| 7 | 7 | __all__ = ["contextmanager", "closing", "ContextDecorator", "ExitStack", | |
| 8 | - "ignored", "redirect_stdout"] | ||
| 8 | + "ignore", "redirect_stdout"] | ||
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | 11 | class ContextDecorator(object): | |
@@ -179,10 +179,10 @@ def __exit__(self, exctype, excinst, exctb): | |||
| 179 | 179 | sys.stdout = self.old_target | |
| 180 | 180 | ||
| 181 | 181 | @contextmanager | |
| 182 | - def ignored(*exceptions): | ||
| 182 | + def ignore(*exceptions): | ||
| 183 | 183 | """Context manager to ignore specified exceptions | |
| 184 | 184 | ||
| 185 | - with ignored(OSError): | ||
| 185 | + with ignore(OSError): | ||
| 186 | 186 | os.remove(somefile) | |
| 187 | 187 | ||
| 188 | 188 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -632,26 +632,26 @@ class Example(object): pass | |||
| 632 | 632 | stack.push(cm) | |
| 633 | 633 | self.assertIs(stack._exit_callbacks[-1], cm) | |
| 634 | 634 | ||
| 635 | - class TestIgnored(unittest.TestCase): | ||
| 635 | + class TestIgnore(unittest.TestCase): | ||
| 636 | 636 | ||
| 637 | 637 | def test_no_exception(self): | |
| 638 | 638 | ||
| 639 | - with ignored(ValueError): | ||
| 639 | + with ignore(ValueError): | ||
| 640 | 640 | self.assertEqual(pow(2, 5), 32) | |
| 641 | 641 | ||
| 642 | 642 | def test_exact_exception(self): | |
| 643 | 643 | ||
| 644 | - with ignored(TypeError): | ||
| 644 | + with ignore(TypeError): | ||
| 645 | 645 | len(5) | |
| 646 | 646 | ||
| 647 | 647 | def test_multiple_exception_args(self): | |
| 648 | 648 | ||
| 649 | - with ignored(ZeroDivisionError, TypeError): | ||
| 649 | + with ignore(ZeroDivisionError, TypeError): | ||
| 650 | 650 | len(5) | |
| 651 | 651 | ||
| 652 | 652 | def test_exception_hierarchy(self): | |
| 653 | 653 | ||
| 654 | - with ignored(LookupError): | ||
| 654 | + with ignore(LookupError): | ||
| 655 | 655 | 'Hello'[50] | |
| 656 | 656 | ||
| 657 | 657 | class TestRedirectStdout(unittest.TestCase): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1656,8 +1656,8 @@ Library | |||
| 1656 | 1656 | - Issue #17385: Fix quadratic behavior in threading.Condition. The FIFO | |
| 1657 | 1657 | queue now uses a deque instead of a list. | |
| 1658 | 1658 | ||
| 1659 | - - Issue #15806: Add contextlib.ignored(). This creates a context manager | ||
| 1660 | - to ignore specified exceptions, replacing the "except Exc: pass" idiom. | ||
| 1659 | + - Issue #15806: Add contextlib.ignore(). This creates a context manager to | ||
| 1660 | + ignore specified exceptions, replacing the "except SomeException: pass" idiom. | ||
| 1661 | 1661 | ||
| 1662 | 1662 | - Issue #14645: The email generator classes now produce output using the | |
| 1663 | 1663 | specified linesep throughout. Previously if the prolog, epilog, or | |
| Back | FazBrowse Home | New Git URL |
0 commit comments