summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-10-01 01:31:21 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-10-01 01:31:21 (GMT)
commit811c2f13695049e0b84bfc6ca390bc064b601365 (patch)
treee964c0a8a2fb5f1ec1fb3f7c4756b7742c642a80 /Lib
parentc759f3e7ec1ba9753d197d3708b379369586f270 (diff)
downloadcpython-811c2f13695049e0b84bfc6ca390bc064b601365.zip
cpython-811c2f13695049e0b84bfc6ca390bc064b601365.tar.gz
cpython-811c2f13695049e0b84bfc6ca390bc064b601365.tar.bz2
remove "fast-path" for (i)adding strings
These were just an artifact of the old unicode concatenation hack and likely just penalized other kinds of adding. Also, this fixes __(i)add__ on string subclasses.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_unicode.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index b903fbe9..a527dff 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1760,6 +1760,18 @@ class UnicodeTest(string_tests.CommonTest,
self.assertEqual(size, nchar)
self.assertEqual(wchar, nonbmp + '\0')
+ def test_subclass_add(self):
+ class S(str):
+ def __add__(self, o):
+ return "3"
+ self.assertEqual(S("4") + S("5"), "3")
+ class S(str):
+ def __iadd__(self, o):
+ return "3"
+ s = S("1")
+ s += "4"
+ self.assertEqual(s, "3")
+
class StringModuleTest(unittest.TestCase):
def test_formatter_parser(self):