[Python-ideas] PEP-3151 pattern-matching

Nick Coghlan ncoghlan at gmail.com
Sat Apr 9 01:50:04 CEST 2011


On Sat, Apr 9, 2011 at 12:31 AM, Mike Graham <mikegraham at gmail.com> wrote:
> On Fri, Apr 8, 2011 at 10:13 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On Sat, Apr 9, 2011 at 12:04 AM, Mike Graham <mikegraham at gmail.com> wrote:
>>> Neither of these seem justified for a rare case (this sort of patter
>>> is fairly rare, most notably this one example) when there's nothing
>>> that awful about the current solution.
>>
>> Actually, there is an awful lot of code in the wild that gives
>> incorrect and wildly misleading error messages *because* correctly
>> checking the errno attribute is so rare. PEP 3151 would improve the
>> quality of information provided by a lot of tracebacks and error
>> messages without many of those developers needing to even set finger
>> to keyboard.
>
> But Nick, that's different from what I'm saying is rare.
>
> I'm saying that the situation where we need an if->raise on a constant
> parameter is rare (this being almost the only common case). The issue
> of whether people handle that case being rare is separate. Neither the
> "except Foo as e if f(e):" syntax nor the "except foo(some_errno):"
> pattern propose something that stops people from doing stupid stuff
> like "except IOError" with no check.

Sorry, I misinterpreted "neither of these" as including PEP 3151
itself (which aims to eliminate the need for most errno pattern
matching). I had missed that someone had brought up a second
pattern-matching idea, and it was the two different approaches that
you were referring to.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list