This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | ncoghlan |
|---|---|
| Recipients | ncoghlan, rhettinger |
| Date | 2013年10月15日.13:01:28 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1381842089.19.0.213446205513.issue19266@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
The specific docs quotes that persuaded me "suppress" was a better name than "ignore" for this feature (by contrast, "ignore" in this sense only appears in its own docs): From http://docs.python.org/dev/library/stdtypes.html#contextmanager.__exit__: "Exit the runtime context and return a Boolean flag indicating if any exception that occurred should be suppressed." "Returning a true value from this method will cause the with statement to suppress the exception and continue execution with the statement immediately following the with statement. " From http://docs.python.org/dev/reference/datamodel.html#object.__exit__ "If an exception is supplied, and the method wishes to suppress the exception (i.e., prevent it from being propagated), it should return a true value." From http://docs.python.org/dev/library/contextlib#contextlib.contextmanager "If an exception is trapped merely in order to log it or to perform some action (rather than to suppress it entirely), the generator must reraise that exception." From http://docs.python.org/dev/library/contextlib#contextlib.ignore (!) "As with any other mechanism that completely suppresses exceptions, it should only be used to cover very specific errors where silently ignoring the exception is known to be the right thing to do." From http://docs.python.org/dev/library/contextlib#contextlib.ExitStack "...if an inner callback suppresses or replaces an exception, then outer callbacks will be passed arguments based on that updated state." From http://docs.python.org/dev/library/contextlib#contextlib.ExitStack.enter_context "These context managers may suppress exceptions just as they normally would if used directly as part of a with statement." From http://docs.python.org/dev/library/contextlib#contextlib.ExitStack.push "By returning true values, these callbacks can suppress exceptions the same way context manager __exit__() methods can." From http://docs.python.org/dev/library/contextlib#contextlib.ExitStack.callback "Unlike the other methods, callbacks added this way cannot suppress exceptions (as they are never passed the exception details)." |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2013年10月15日 13:01:29 | ncoghlan | set | recipients: + ncoghlan, rhettinger |
| 2013年10月15日 13:01:29 | ncoghlan | set | messageid: <1381842089.19.0.213446205513.issue19266@psf.upfronthosting.co.za> |
| 2013年10月15日 13:01:29 | ncoghlan | link | issue19266 messages |
| 2013年10月15日 13:01:28 | ncoghlan | create | |