SF 1193128: Let str.translate(None) be an identity transformation
diff --git a/Lib/string.py b/Lib/string.py
index 921bd8b..9e3cc41 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -487,7 +487,7 @@
deletions argument is not allowed for Unicode strings.
"""
- if deletions:
+ if deletions or table is None:
return s.translate(table, deletions)
else:
# Add s[:0] so that if s is Unicode and table is an 8-bit string,
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index 1aa68de..16161f3 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -1096,6 +1096,9 @@
self.checkequal('Abc', 'abc', 'translate', table)
self.checkequal('xyz', 'xyz', 'translate', table)
self.checkequal('yz', 'xyz', 'translate', table, 'x')
+ self.checkequal('yx', 'zyzzx', 'translate', None, 'z')
+ self.checkequal('zyzzx', 'zyzzx', 'translate', None, '')
+ self.checkequal('zyzzx', 'zyzzx', 'translate', None)
self.checkraises(ValueError, 'xyz', 'translate', 'too short', 'strip')
self.checkraises(ValueError, 'xyz', 'translate', 'too short')