[
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.
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')
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):
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;
}
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;
}