Final tweaks:
- fix the __str__, __unicode__ and __repr__ methods - some textual tweaks - add Python 3.0 to the transition plan
This commit is contained in:
parent
0fcf41f3cd
commit
3040eb4a06
32
pep-0352.txt
32
pep-0352.txt
|
@ -71,20 +71,19 @@ will cause the deprecation of the existing ``args`` attribute)::
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Return the str of 'message'"""
|
"""Return the str of 'message'"""
|
||||||
return str(self.message
|
return str(self.message
|
||||||
if not self.args
|
if len(self.args) <= 1
|
||||||
else self.args)
|
else self.args)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
"""Return the unicode of 'message'"""
|
"""Return the unicode of 'message'"""
|
||||||
return unicode(self.message
|
return unicode(self.message
|
||||||
if not self.args
|
if len(self.args) <= 1
|
||||||
else self.args)
|
else self.args)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
args_repr = (repr(self.message)
|
if (len(self.args) <= 1):
|
||||||
if not self.args
|
return "%s(%r)" % (self.__class__.__name__, self.message)
|
||||||
else "*%r" % self.args)
|
return "%s%r" % (self.__class__.__name__, self.args)
|
||||||
return "%s(%s)" % (self.__class__.__name__, args_repr)
|
|
||||||
|
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
"""Index into arguments passed in during instantiation.
|
"""Index into arguments passed in during instantiation.
|
||||||
|
@ -96,16 +95,16 @@ will cause the deprecation of the existing ``args`` attribute)::
|
||||||
return self.args[index]
|
return self.args[index]
|
||||||
|
|
||||||
|
|
||||||
The ``message`` attribute will contain either the argument passed in
|
The ``message`` attribute will contain either the first argument
|
||||||
at instantiation of the object or the empty string. The attribute is
|
passed in at instantiation of the object or the empty string if no
|
||||||
meant to act as a common location to store any extra information that
|
arguments were passed in. The attribute is meant to act as a common
|
||||||
is to be passed along with the exception that goes beyond the location
|
location to store any extra information that is to be passed along
|
||||||
of the exception within the exception hierarchy and the exception's
|
with the exception that goes beyond the location of the exception
|
||||||
type.
|
within the exception hierarchy and the exception's type.
|
||||||
|
|
||||||
No restriction is placed upon what may be passed in for ``messsage``.
|
No restriction is placed upon what may be passed in for ``messsage``.
|
||||||
This provides backwards-compatibility with how the argument passed
|
This provides backwards-compatibility with how the arguments passed
|
||||||
into Exception has no restrictions.
|
into Exception have no restrictions.
|
||||||
|
|
||||||
The ``args`` attribute is deprecated. While allowing multiple
|
The ``args`` attribute is deprecated. While allowing multiple
|
||||||
arguments to be passed can be helpful, it is in no way essential. It
|
arguments to be passed can be helpful, it is in no way essential. It
|
||||||
|
@ -214,11 +213,14 @@ specifically listed.
|
||||||
|
|
||||||
- deprecate catching exceptions that do not inherit from BaseException
|
- deprecate catching exceptions that do not inherit from BaseException
|
||||||
|
|
||||||
|
|
||||||
* Python 2.9
|
* Python 2.9
|
||||||
|
|
||||||
- deprecate ``args`` and ``__getitem__``
|
- deprecate ``args`` and ``__getitem__``
|
||||||
|
|
||||||
|
* Python 3.0
|
||||||
|
|
||||||
|
- drop ``args`` and ``__getitem__``
|
||||||
|
|
||||||
|
|
||||||
References
|
References
|
||||||
==========
|
==========
|
||||||
|
|
Loading…
Reference in New Issue