[Python-Dev] Re: PEP 246: LiskovViolation as a name

Phillip J. Eby pje at telecommunity.com
Thu Jan 13 01:49:06 CET 2005


At 02:03 PM 1/12/05 -0600, Skip Montanaro wrote:

>I don't think that's appropriate in this case.  Liskov violation is
>something precise.  I don't think that changing what you call it will help
>beginners understand it any better in this case.  I say leave it as it and
>make sure it's properly documented.

Actually, the whole discussion is kind of backwards; you should never *get* 
a Liskov violation error, because it's raised strictly for control flow 
inside of __conform__ and caught by adapt().  So the *only* way you can see 
this error is if you call __conform__ directly, and somebody added code 
like this:

     raise LiskovViolation

So, it's not something you need to worry about a newbie seeing.  The *real* 
problem with the name is knowing that you need to use it in the first place!

IMO, it's simpler to handle this use case by letting __conform__ return 
None, since this allows people to follow the One Obvious Way to not conform 
to a particular protocol.

Then, there isn't a need to even worry about the exception name in the 
first place, either...




More information about the Python-Dev mailing list