summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-08-12 17:34:49 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2003-08-12 17:34:49 (GMT)
commita54b92b2ebcbaaa4b7f77ff411a73a820522a67b (patch)
tree9dfce3c6eb66228f55534f955ef4dde12bc71e13
parentfd196bd263c0474c2d40dc2505ce76d4a8f1b9e2 (diff)
downloadcpython-a54b92b2ebcbaaa4b7f77ff411a73a820522a67b.zip
cpython-a54b92b2ebcbaaa4b7f77ff411a73a820522a67b.tar.gz
cpython-a54b92b2ebcbaaa4b7f77ff411a73a820522a67b.tar.bz2
Add a unicode prefix to the characters in the UnicodeEncodeError and
UnicodeTranslateError message.
-rw-r--r--Lib/test/test_codeccallbacks.py18
-rw-r--r--Python/exceptions.c12
2 files changed, 15 insertions, 15 deletions
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index 4552462..ae75229 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -258,7 +258,7 @@ class CodecCallbackTest(unittest.TestCase):
self.check_exceptionobjectargs(
UnicodeEncodeError,
["ascii", u"g\xfcrk", 1, 2, "ouch"],
- "'ascii' codec can't encode character '\\xfc' in position 1: ouch"
+ "'ascii' codec can't encode character u'\\xfc' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeEncodeError,
@@ -268,23 +268,23 @@ class CodecCallbackTest(unittest.TestCase):
self.check_exceptionobjectargs(
UnicodeEncodeError,
["ascii", u"\xfcx", 0, 1, "ouch"],
- "'ascii' codec can't encode character '\\xfc' in position 0: ouch"
+ "'ascii' codec can't encode character u'\\xfc' in position 0: ouch"
)
self.check_exceptionobjectargs(
UnicodeEncodeError,
["ascii", u"\u0100x", 0, 1, "ouch"],
- "'ascii' codec can't encode character '\\u0100' in position 0: ouch"
+ "'ascii' codec can't encode character u'\\u0100' in position 0: ouch"
)
self.check_exceptionobjectargs(
UnicodeEncodeError,
["ascii", u"\uffffx", 0, 1, "ouch"],
- "'ascii' codec can't encode character '\\uffff' in position 0: ouch"
+ "'ascii' codec can't encode character u'\\uffff' in position 0: ouch"
)
if sys.maxunicode > 0xffff:
self.check_exceptionobjectargs(
UnicodeEncodeError,
["ascii", u"\U00010000x", 0, 1, "ouch"],
- "'ascii' codec can't encode character '\\U00010000' in position 0: ouch"
+ "'ascii' codec can't encode character u'\\U00010000' in position 0: ouch"
)
def test_unicodedecodeerror(self):
@@ -303,23 +303,23 @@ class CodecCallbackTest(unittest.TestCase):
self.check_exceptionobjectargs(
UnicodeTranslateError,
[u"g\xfcrk", 1, 2, "ouch"],
- "can't translate character '\\xfc' in position 1: ouch"
+ "can't translate character u'\\xfc' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeTranslateError,
[u"g\u0100rk", 1, 2, "ouch"],
- "can't translate character '\\u0100' in position 1: ouch"
+ "can't translate character u'\\u0100' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeTranslateError,
[u"g\uffffrk", 1, 2, "ouch"],
- "can't translate character '\\uffff' in position 1: ouch"
+ "can't translate character u'\\uffff' in position 1: ouch"
)
if sys.maxunicode > 0xffff:
self.check_exceptionobjectargs(
UnicodeTranslateError,
[u"g\U00010000rk", 1, 2, "ouch"],
- "can't translate character '\\U00010000' in position 1: ouch"
+ "can't translate character u'\\U00010000' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeTranslateError,
diff --git a/Python/exceptions.c b/Python/exceptions.c
index d49b364..da78f2b 100644
--- a/Python/exceptions.c
+++ b/Python/exceptions.c
@@ -1254,11 +1254,11 @@ UnicodeEncodeError__str__(PyObject *self, PyObject *arg)
int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start];
char *format;
if (badchar <= 0xff)
- format = "'%.400s' codec can't encode character '\\x%02x' in position %d: %.400s";
+ format = "'%.400s' codec can't encode character u'\\x%02x' in position %d: %.400s";
else if (badchar <= 0xffff)
- format = "'%.400s' codec can't encode character '\\u%04x' in position %d: %.400s";
+ format = "'%.400s' codec can't encode character u'\\u%04x' in position %d: %.400s";
else
- format = "'%.400s' codec can't encode character '\\U%08x' in position %d: %.400s";
+ format = "'%.400s' codec can't encode character u'\\U%08x' in position %d: %.400s";
PyOS_snprintf(buffer, sizeof(buffer),
format,
PyString_AS_STRING(encodingObj),
@@ -1449,11 +1449,11 @@ UnicodeTranslateError__str__(PyObject *self, PyObject *arg)
int badchar = (int)PyUnicode_AS_UNICODE(objectObj)[start];
char *format;
if (badchar <= 0xff)
- format = "can't translate character '\\x%02x' in position %d: %.400s";
+ format = "can't translate character u'\\x%02x' in position %d: %.400s";
else if (badchar <= 0xffff)
- format = "can't translate character '\\u%04x' in position %d: %.400s";
+ format = "can't translate character u'\\u%04x' in position %d: %.400s";
else
- format = "can't translate character '\\U%08x' in position %d: %.400s";
+ format = "can't translate character u'\\U%08x' in position %d: %.400s";
PyOS_snprintf(buffer, sizeof(buffer),
format,
badchar,