[Python-checkins] r42306 - peps/trunk/pep-0000.txt peps/trunk/pep-0352.txt
guido.van.rossum
python-checkins at python.org
Fri Feb 10 20:48:39 CET 2006
Author: guido.van.rossum
Date: Fri Feb 10 20:48:38 2006
New Revision: 42306
Modified:
peps/trunk/pep-0000.txt
peps/trunk/pep-0352.txt
Log:
Tweak and accept PEP 352 -- new exception hierarchy.
Modified: peps/trunk/pep-0000.txt
==============================================================================
--- peps/trunk/pep-0000.txt (original)
+++ peps/trunk/pep-0000.txt Fri Feb 10 20:48:38 2006
@@ -68,6 +68,7 @@
SA 308 Conditional Expressions GvR, Hettinger
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)
@@ -105,7 +106,6 @@
S 345 Metadata for Python Software Packages 1.2 Jones
I 350 Codetags Elliott
S 351 The freeze protocol Warsaw
- S 352 Required Superclass for Exceptions GvR, Cannon
S 353 Using ssize_t as the index type von Loewis
S 354 Enumerations in Python Finney
S 355 Path - Object oriented filesystem paths Lindqvist
@@ -404,7 +404,7 @@
SD 349 Allow str() to return unicode strings Schemenauer
I 350 Codetags Elliott
S 351 The freeze protocol Warsaw
- S 352 Required Superclass for Exceptions GvR, Cannon
+ SA 352 Required Superclass for Exceptions GvR, Cannon
S 353 Using ssize_t as the index type von Loewis
S 354 Enumerations in Python Finney
S 355 Path - Object oriented filesystem paths Lindqvist
Modified: peps/trunk/pep-0352.txt
==============================================================================
--- peps/trunk/pep-0352.txt (original)
+++ peps/trunk/pep-0352.txt Fri Feb 10 20:48:38 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: Draft
+Status: Accepted
Type: Standards Track
Content-Type: text/x-rst
Created: 27-Oct-2005
@@ -34,12 +34,15 @@
to rearrange the exception hierarchy slightly for the better. As it
currently stands, all exceptions in the built-in namespace inherit
from Exception. This is a problem since this includes two exceptions
-(KeyboardInterrupt and SystemExit) that are usually meant to signal
-that the interpreter should be shut down. Changing it so that these
-two exceptions inherit from the common superclass instead of Exception
-will make it easy for people to write ``except`` clauses that are not
-overreaching and not catch exceptions that should propagate up and
-terminate the interpreter.
+(KeyboardInterrupt and SystemExit) that often need to be excepted from
+the application's exception handling: the default behavior of shutting
+the interpreter down with resp. without a traceback is usually more
+desirable than whatever the application might do (with the possible
+exception of applications that emulate Python's interactive command
+loop with ``>>>`` prompt). Changing it so that these two exceptions
+inherit from the common superclass instead of Exception will make it
+easy for people to write ``except`` clauses that are not overreaching
+and not catch exceptions that should propagate up.
This PEP is based on previous work done for PEP 348 [#pep348]_.
@@ -81,9 +84,13 @@
else self.args)
def __repr__(self):
- if (len(self.args) <= 1):
- return "%s(%r)" % (self.__class__.__name__, self.message)
- return "%s%r" % (self.__class__.__name__, self.args)
+ 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
def __getitem__(self, index):
"""Index into arguments passed in during instantiation.
@@ -201,11 +208,11 @@
* Python 2.5
- - introduce BaseException
+ - allow exceptions to be new-style classes
- + allow exceptions to be new-style classes
+ - all standard exceptions become new-style classes
- + all standard exceptions become new-style classes
+ - introduce BaseException
- Exception, KeyboardInterrupt, and SystemExit inherit from BaseException
@@ -229,7 +236,13 @@
* Python 3.0
- - drop ``args`` and ``__getitem__``
+ - drop everything that was deprecated above:
+
+ + drop string exceptions (could do this sooner?)
+
+ + all exceptions must inherit from BaseException
+
+ + drop ``args`` and ``__getitem__``
Implementation
More information about the Python-checkins
mailing list