[Python-Dev] RE: PEP-317
Michael Chermside
mcherm@mcherm.com
2003年6月11日 04:27:25 -0700
Guido writes:
> It would be simple enough to introduce new-style exceptions if
> Exception were made a new-style class and at the same time all
> new-style exceptions were required to derive from Exception:
>> raise x
>> would check whether x was:
>> - a string (but not an instance of a true subclass of str)
> - a classic class
> - an instance of a classic class
> - Exception or a subclass thereof
> - an instance of Exception or of a subclass thereof
>> Where the first three cases are for backward compatibility.
>> Similarly, the rule for
>> raise x, y
>> should allows x to be
>> - a string
> - a classic class
> - Exception or a subclass thereof
>> and in the last two cases, y could either be an instance of x (or of a
> subclass of x!), or an argument for x, or a tuple of arguments for x.
Okay, after hearing this (plus all the arguments about PEP 317
requiring an excessive level of migration pain), I am now convinced.
If the PEP winds up being officially rejected, I propose that it
grow a "rejection reasons" section explaing why, and that this section
also describe the above plan as the "plausible alternative" to PEP 317
for eventual migration to new-style exceptions.
-- Michael Chermside