exc = Exception(arg)
results = ([len(exc.args), 1], [exc.args[0], arg],
[str(exc), str(arg)],
- [repr(exc), exc.__class__.__name__ + repr(exc.args)])
+ [repr(exc), '%s(%r)' % (exc.__class__.__name__, arg)])
self.interface_test_driver(results)
def test_interface_multi_arg(self):
def test_bad_status_repr(self):
exc = client.BadStatusLine('')
- self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''')
+ self.assertEqual(repr(exc), '''BadStatusLine("''")''')
def test_partial_reads(self):
# if we have Content-Length, HTTPResponse knows when to close itself,
"Yielded g2 spam",
"Yielded g2 more spam",
"Finishing g2",
- "g2 returned StopIteration(3,)",
+ "g2 returned StopIteration(3)",
"Yielded g1 eggs",
"Finishing g1",
])
"g starting",
"f resuming g",
"g returning 1",
- "f caught StopIteration(1,)",
+ "f caught StopIteration(1)",
"g starting",
"f resuming g",
"g returning (2,)",
- "f caught StopIteration((2,),)",
+ "f caught StopIteration((2,))",
"g starting",
"f resuming g",
- "g returning StopIteration(3,)",
- "f caught StopIteration(StopIteration(3,),)",
+ "g returning StopIteration(3)",
+ "f caught StopIteration(StopIteration(3))",
])
def test_send_and_return_with_value(self):
"f sending spam to g",
"g received 'spam'",
"g returning 1",
- 'f caught StopIteration(1,)',
+ 'f caught StopIteration(1)',
'g starting',
'f sending spam to g',
"g received 'spam'",
'g returning (2,)',
- 'f caught StopIteration((2,),)',
+ 'f caught StopIteration((2,))',
'g starting',
'f sending spam to g',
"g received 'spam'",
- 'g returning StopIteration(3,)',
- 'f caught StopIteration(StopIteration(3,),)'
+ 'g returning StopIteration(3)',
+ 'f caught StopIteration(StopIteration(3))'
])
def test_catching_exception_from_subgen_and_returning(self):
BaseException_repr(PyBaseExceptionObject *self)
{
const char *name = _PyType_Name(Py_TYPE(self));
- return PyUnicode_FromFormat("%s%R", name, self->args);
+ if (PyTuple_GET_SIZE(self->args) == 1)
+ return PyUnicode_FromFormat("%s(%R)", name,
+ PyTuple_GET_ITEM(self->args, 0));
+ else
+ return PyUnicode_FromFormat("%s%R", name, self->args);
}
/* Pickling support */