[Python-checkins] r42714 - peps/trunk/pep-0000.txt peps/trunk/pep-0352.txt

Jim Jewett jimjjewett at gmail.com
Fri Mar 3 22:10:25 CET 2006


The new wording suggests that I could no longer do

    class MyErr(Exception): pass

since MyErr is not builtin, but would now be new-style.

Perhaps reword it as

    new-style classes and instances can now be raised if -- and only if --
they inherit from BaseException.

On 2/28/06, brett.cannon <python-checkins at python.org> wrote:
>
> Author: brett.cannon
> Date: Wed Mar  1 05:48:52 2006
> New Revision: 42714
>
> Modified:
>    peps/trunk/pep-0000.txt
>    peps/trunk/pep-0352.txt
> Log:
> Change status of PEP 352 to final.
>
> Also clarified wording to reflect the implementation; only exceptions are
> new-style class.  Wording was ambiguous and suggested that you could raise
> any new-style class which was considered insane by everyone at the core
> sprint
> at PyCon 2006.  And, most importantly, a Tim-channeled Guido thought that
> the
> current implementation was the way to go.  No one should be able to
> ``raise
> 42``.
>
>
> Modified: peps/trunk/pep-0000.txt
>
> ==============================================================================
> --- peps/trunk/pep-0000.txt     (original)
> +++ peps/trunk/pep-0000.txt     Wed Mar  1 05:48:52 2006
> @@ -67,7 +67,6 @@
>
>   SA  328  Imports: Multi-Line and Absolute/Relative    Aahz
>   SA  343  The "with" Statement                         GvR, Coghlan
> - SA  352  Required Superclass for Exceptions           GvR, Cannon
>
>   Open PEPs (under consideration)
>
> @@ -166,6 +165,7 @@
>   SF  327  Decimal Data Type                            Batista
>   SF  341  Unifying try-except and try-finally          Brandl
>   SF  342  Coroutines via Enhanced Generators           GvR, Eby
> + SF  352  Required Superclass for Exceptions           GvR, Cannon
>   SF  353  Using ssize_t as the index type              von Loewis
>
>   Empty PEPs (or containing only an abstract)
>
> Modified: peps/trunk/pep-0352.txt
>
> ==============================================================================
> --- peps/trunk/pep-0352.txt     (original)
> +++ peps/trunk/pep-0352.txt     Wed Mar  1 05:48:52 2006
> @@ -3,7 +3,7 @@
> Version: $Revision$
> Last-Modified: $Date$
> Author: Brett Cannon <brett at python.org>, Guido van Rossum <
> guido at python.org>
> -Status: Accepted
> +Status: Final
> Type: Standards Track
> Content-Type: text/x-rst
> Created: 27-Oct-2005
> @@ -16,10 +16,11 @@
> In Python 2.4 and before, any (classic) class can be raised as an
> exception.  The plan is to allow new-style classes starting in Python
> 2.5, but this makes the problem worse -- it would mean *any* class (or
> -instance) can be raised!  This is a problem since it prevents any
> -guarantees to be made about the interface of exceptions.  This PEP
> -proposes introducing a new superclass that all raised objects must
> -inherit from.  Imposing the restriction will allow a standard
> +instance) can be raised (this is not the case in the final version;
> +only built-in exceptions can be new-style)!  This is a problem since it
> +prevents any guarantees to be made about the interface of exceptions.
> +This PEP proposes introducing a new superclass that all raised objects
> +must inherit from.  Imposing the restriction will allow a standard
> interface for exceptions to exist that can be relied upon.
>
> One might counter that requiring a specific base class for a
> @@ -86,8 +87,6 @@
>        def __repr__(self):
>            if not self.args:
>                argss = "()"
> -          elif len(self.args) <= 1:
> -              argss = "(%s)" % repr(self.message)
>            else:
>                argss = repr(self.args)
>            return self.__class__.__name__ + argss
> @@ -208,8 +207,6 @@
>
> * Python 2.5
>
> -  - allow exceptions to be new-style classes
> -
>    - all standard exceptions become new-style classes
>
>    - introduce BaseException
> @@ -248,12 +245,7 @@
> Implementation
> ==============
>
> -An initial patch to make exceptions new-style classes has been
> -authored by Michael Hudson can be found at SF patch #1104669
> -[#SF_1104669]_.  While it does not implement all points mentioned in
> -this PEP, it will most likely be used as a basis for the final path
> -to implement this PEP.
> -
> +The initial implementation of this PEP has been checked into Python 2.5 .
>
> References
> ==========
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-checkins/attachments/20060303/9a0897f3/attachment.htm 


More information about the Python-checkins mailing list