[Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore(). (original) (raw)

PJ Eby pje at telecommunity.com
Tue Oct 15 18:40:44 CEST 2013


On Tue, Oct 15, 2013 at 8:57 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

So, having been convinced that "ignore" was the wrong choice of name, reviewing the docs made it clear to me what the name should be.

From the point of view of code outside a block, the error is indeed suppressed.

But, as one of those examples actually points out, what's happening from the POV inside the block is that the exception is "trapped".

So using "suppress" creates an ambiguity: are we suppressing these errors inside the block, or outside the block? The way it actually works is errors are suppressed from the code surrounding the block, but the word can equally be interpreted as suppressing errors inside the block, in exactly the same way that "ignore" can be misread.

So, if we're going with words that have precedent in the doc, the term "trap", as used here:

"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."

is the only one used to describe the POV from inside the block, where the error is... well, being trapped. ;-)

It is a more apt description of what actually happens, even if it's only usable for the specific use case where an exception is trapped in order to suppress it.



More information about the Python-Dev mailing list