[Python-3000-checkins] r54800 - in python/branches/p3yk: Lib/test/test_bytes.py Objects/unicodeobject.c

guido.van.rossum python-3000-checkins at python.org
Fri Apr 13 04:24:02 CEST 2007


Author: guido.van.rossum
Date: Fri Apr 13 04:23:57 2007
New Revision: 54800

Modified:
   python/branches/p3yk/Lib/test/test_bytes.py
   python/branches/p3yk/Objects/unicodeobject.c
Log:
Disallow u"..." + b"..." and b"..." + u"...".


Modified: python/branches/p3yk/Lib/test/test_bytes.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_bytes.py	(original)
+++ python/branches/p3yk/Lib/test/test_bytes.py	Fri Apr 13 04:23:57 2007
@@ -374,7 +374,7 @@
         self.assertEqual(b1 + "def", bytes("abcdef"))
         self.assertEqual("def" + b1, bytes("defabc"))
         self.assertRaises(TypeError, lambda: b1 + u"def")
-        ##self.assertRaises(TypeError, lambda: u"abc" + b2)  # XXX FIXME
+        self.assertRaises(TypeError, lambda: u"abc" + b2)
 
     def test_repeat(self):
         b = bytes("abc")

Modified: python/branches/p3yk/Objects/unicodeobject.c
==============================================================================
--- python/branches/p3yk/Objects/unicodeobject.c	(original)
+++ python/branches/p3yk/Objects/unicodeobject.c	Fri Apr 13 04:23:57 2007
@@ -5535,6 +5535,9 @@
 {
     PyUnicodeObject *u = NULL, *v = NULL, *w;
 
+    if (PyBytes_Check(left) || PyBytes_Check(right))
+        return PyBytes_Concat(left, right);
+
     /* Coerce the two arguments */
     u = (PyUnicodeObject *)PyUnicode_FromObject(left);
     if (u == NULL)


More information about the Python-3000-checkins mailing list