From: Walter Dörwald <walter@livinglogic.de>
Date: Wed, 4 Sep 2002 20:31:32 +0000 (+0000)
Subject: Change the unicode.translate docstring to document that
X-Git-Tag: v2.3c1~4214
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c1ee17742f21cd819519c4835eb6a958902cdb0;p=python

Change the unicode.translate docstring to document that
Unicode strings (with arbitrary length) are allowed
as entries in the unicode.translate mapping.

Add a test case for multicharacter replacements.

(Multicharacter replacements were enabled by the
PEP 293 patch)
---

diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 9e36316d79..7f7041298b 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -405,6 +405,8 @@ test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'\n', u'abc\n', u'def\r\n', u'ghi
 test('translate', u"abababc", u'bbbc', {ord('a'):None})
 test('translate', u"abababc", u'iiic', {ord('a'):None, ord('b'):ord('i')})
 test('translate', u"abababc", u'iiix', {ord('a'):None, ord('b'):ord('i'), ord('c'):u'x'})
+test('translate', u"abababc", u'<i><i><i>c', {ord('a'):None, ord('b'):u'<i>'})
+test('translate', u"abababc", u'c', {ord('a'):None, ord('b'):u''})
 
 # Contains:
 print 'Testing Unicode contains method...',
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 2108d94863..dab3a75ab6 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -5610,8 +5610,9 @@ PyDoc_STRVAR(translate__doc__,
 \n\
 Return a copy of the string S, where all characters have been mapped\n\
 through the given translation table, which must be a mapping of\n\
-Unicode ordinals to Unicode ordinals or None. Unmapped characters\n\
-are left untouched. Characters mapped to None are deleted.");
+Unicode ordinals to Unicode ordinals, Unicode strings or None.\n\
+Unmapped characters are left untouched. Characters mapped to None\n\
+are deleted.");
 
 static PyObject*
 unicode_translate(PyUnicodeObject *self, PyObject *table)