[pypy-svn] r16544 - pypy/dist/pypy/lib
ale at codespeak.net
ale at codespeak.net
Thu Aug 25 20:35:44 CEST 2005
Author: ale
Date: Thu Aug 25 20:35:42 2005
New Revision: 16544
Modified:
pypy/dist/pypy/lib/_exceptions.py
Log:
(arre, ale)
Changed the __str__ method of UnicodeEncodeError and UnicodeDecodeError to match CPython (and not to generate exceptions when trying to raise exceptions)
Modified: pypy/dist/pypy/lib/_exceptions.py
==============================================================================
--- pypy/dist/pypy/lib/_exceptions.py (original)
+++ pypy/dist/pypy/lib/_exceptions.py Thu Aug 25 20:35:42 2005
@@ -354,16 +354,8 @@
raise TypeError('function takes exactly 5 arguments (%d given)'%argc)
def __str__(self):
- # this is a bad hack, please supply an implementation
- res = ' '.join([
- 'object=' + str(getattr(self, 'object', None)),
- 'end=' + str(getattr(self, 'end', None)),
- 'encoding=' + str(getattr(self, 'encoding', None)),
- 'args=' + str(getattr(self, 'args', None)),
- 'start=' + str(getattr(self, 'start', None)),
- 'reason=' + str(getattr(self, 'reason', None)),
- ])
- return res
+ return "%r codec can't decode byte %x in position %d: %s"%(self.encoding,
+ ord(self.object[self.start]), self.start, self.reason)
class TypeError(StandardError):
"""Inappropriate argument type."""
@@ -429,13 +421,5 @@
raise TypeError('function takes exactly 5 arguments (%d given)'%argc)
def __str__(self):
- # this is a bad hack, please supply an implementation
- res = ' '.join([
- 'object=' + str(getattr(self, 'object', None)),
- 'end=' + str(getattr(self, 'end', None)),
- 'encoding=' + str(getattr(self, 'encoding', None)),
- 'args=' + str(getattr(self, 'args', None)),
- 'start=' + str(getattr(self, 'start', None)),
- 'reason=' + str(getattr(self, 'reason', None)),
- ])
- return res
+ return "%r codec can't encode character %r in position %d: %s"%(self.encoding,
+ self.object[self.start], self.start, self.reason)
More information about the Pypy-commit
mailing list