[Python-checkins] commit of r41362 - peps/trunk

guido.van.rossum@python.org guido.van.rossum at python.org
Mon Oct 31 20:22:43 CET 2005


Author: guido.van.rossum
Date: Mon Oct 31 20:22:43 2005
New Revision: 41362

Modified:
   peps/trunk/pep-0352.txt
Log:
Final tweaks:

- fix the __str__, __unicode__ and __repr__ methods
- some textual tweaks
- add Python 3.0 to the transition plan



Modified: peps/trunk/pep-0352.txt
==============================================================================
--- peps/trunk/pep-0352.txt	(original)
+++ peps/trunk/pep-0352.txt	Mon Oct 31 20:22:43 2005
@@ -65,47 +65,46 @@
 
       def __init__(self, *args):
           """Set 'message' and 'args' attribute"""
-	  self.args = args
-	  self.message = args[0] if args else ''
+          self.args = args
+          self.message = args[0] if args else ''
 
       def __str__(self):
-	  """Return the str of 'message'"""
-	  return str(self.message
-			if not self.args
-			else self.args)
+          """Return the str of 'message'"""
+          return str(self.message
+                     if len(self.args) <= 1
+                     else self.args)
 
       def __unicode__(self):
-	  """Return the unicode of 'message'"""
-	  return unicode(self.message
-			    if not self.args
-			    else self.args)
+          """Return the unicode of 'message'"""
+          return unicode(self.message
+                         if len(self.args) <= 1
+                         else self.args)
 
       def __repr__(self):
-	  args_repr = (repr(self.message)
-		       	if not self.args
-			else "*%r" % self.args)
-          return "%s(%s)" % (self.__class__.__name__, args_repr)
+          if (len(self.args) <= 1):
+              return "%s(%r)" % (self.__class__.__name__, self.message)
+          return "%s%r" % (self.__class__.__name__, self.args)
 
       def __getitem__(self, index):
           """Index into arguments passed in during instantiation.
 
-	  Provided for backwards-compatibility and will be
-	  deprecated.
+          Provided for backwards-compatibility and will be
+          deprecated.
 
-	  """
-	  return self.args[index]
+          """
+          return self.args[index]
 
 
-The ``message`` attribute will contain either the argument passed in
-at instantiation of the object or the empty string.  The attribute is
-meant to act as a common location to store any extra information that
-is to be passed along with the exception that goes beyond the location
-of the exception within the exception hierarchy and the exception's
-type.
+The ``message`` attribute will contain either the first argument
+passed in at instantiation of the object or the empty string if no
+arguments were passed in.  The attribute is meant to act as a common
+location to store any extra information that is to be passed along
+with the exception that goes beyond the location of the exception
+within the exception hierarchy and the exception's type.
 
 No restriction is placed upon what may be passed in for ``messsage``.
-This provides backwards-compatibility with how the argument passed
-into Exception has no restrictions.
+This provides backwards-compatibility with how the arguments passed
+into Exception have no restrictions.
 
 The ``args`` attribute is deprecated.  While allowing multiple
 arguments to be passed can be helpful, it is in no way essential.  It
@@ -214,11 +213,14 @@
 
   - deprecate catching exceptions that do not inherit from BaseException
 
-
 * Python 2.9
   
   - deprecate ``args`` and ``__getitem__``
 
+* Python 3.0
+
+  - drop ``args`` and ``__getitem__``
+
 
 References
 ==========


More information about the Python-checkins mailing list