]> granicus.if.org Git - python/commitdiff
Fix bug:
authorMichael W. Hudson <mwh@python.net>
Fri, 21 Oct 2005 11:45:01 +0000 (11:45 +0000)
committerMichael W. Hudson <mwh@python.net>
Fri, 21 Oct 2005 11:45:01 +0000 (11:45 +0000)
1327110 ] wrong TypeError traceback in generator expressions

by removing the code that can stomp on the users' TypeError raised by the
iterable argument to ''.join() -- PySequence_Fast (now?) gives a perfectly
reasonable message itself.  Also, a couple of tests.

Lib/test/string_tests.py
Lib/test/test_string.py
Objects/stringobject.c
Objects/unicodeobject.c

index 9f092b97937ab16b5cfb780f84b990c8f6190373..60f5fdb2a5eadc7b6b7c09a61386e143820369ca 100644 (file)
@@ -657,6 +657,15 @@ class MixinStrUnicodeUserStringTest:
         self.checkraises(TypeError, ' ', 'join')
         self.checkraises(TypeError, ' ', 'join', 7)
         self.checkraises(TypeError, ' ', 'join', Sequence([7, 'hello', 123L]))
+        try:
+            def f():
+                yield 4 + ""
+            self.fixtype(' ').join(f())
+        except TypeError, e:
+            if '+' not in str(e):
+                self.fail('join() ate exception message')
+        else:
+            self.fail('exception not raised')
 
     def test_formatting(self):
         self.checkequal('+hello+', '+%s+', '__mod__', 'hello')
index d80c3b60436d00b4dda91d6bb104d1648501f687..fdd431d2496b4184822bb78be90b3aa7f70bc1cb 100644 (file)
@@ -51,6 +51,17 @@ class StringTest(
 
         self.checkraises(TypeError, string_tests.BadSeq1(), 'join', ' ')
         self.checkequal('a b c', string_tests.BadSeq2(), 'join', ' ')
+        try:
+            def f():
+                yield 4 + ""
+            self.fixtype(' ').join(f())
+        except TypeError, e:
+            if '+' not in str(e):
+                self.fail('join() ate exception message')
+        else:
+            self.fail('exception not raised')
+
+
 
 
 class ModuleTest(unittest.TestCase):
index 78560de9d6bcf4ea2557cc37ac57cca66c64945a..037fa6a239ea022e567d7da556a34d38df7e1891 100644 (file)
@@ -1620,10 +1620,6 @@ string_join(PyStringObject *self, PyObject *orig)
 
        seq = PySequence_Fast(orig, "");
        if (seq == NULL) {
-               if (PyErr_ExceptionMatches(PyExc_TypeError))
-                       PyErr_Format(PyExc_TypeError,
-                                    "sequence expected, %.80s found",
-                                    orig->ob_type->tp_name);
                return NULL;
        }
 
index 10ac80c9a2ef32a69f3e328afa01ac4f2efc6ab5..db2a6900cb46161dd571d28e98c3d41f47c63de7 100644 (file)
@@ -4148,10 +4148,6 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
 
     fseq = PySequence_Fast(seq, "");
     if (fseq == NULL) {
-       if (PyErr_ExceptionMatches(PyExc_TypeError))
-           PyErr_Format(PyExc_TypeError,
-                        "sequence expected, %.80s found",
-                        seq->ob_type->tp_name);
        return NULL;
     }