This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amyodov
Recipients amyodov
Date 2011-10-26.15:43:48
SpamBayes Score 0.0003485701
Marked as misclassified No
Message-id <1319643837.13.0.0801682507198.issue13268@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-10-26 15:43:57amyodovsetrecipients: + amyodov
2011-10-26 15:43:57amyodovsetmessageid: <1319643837.13.0.0801682507198.issue13268@psf.upfronthosting.co.za>
2011-10-26 15:43:49amyodovlinkissue13268 messages
2011-10-26 15:43:48amyodovcreate