Issue 13268: assert statement violates the documentation (original) (raw)
The extended version of assert statement has a strange violation of documented behaviour.
According to the http://docs.python.org/reference/simple_stmts.html#the-assert-statement, "assert expression1, expression2" should be equivalent to "if debug: if not expression1: raise AssertionError(expression2)". Nevertheless, it is not so for the following scenario:
class A(object): def str(self): return "str" def unicode(self): return "unicode" def repr(self): return "repr"
expression1 = False expression2 = (A(),)
That is, when expression2 is a single-item tuple, assert statement prints the str-evaluation of the item itself, rather than of the tuple.
This occurs in 2.x branch only, seems fixed in 3.x, and it would be great to have it backported for consistency.