New submission from Alexander Myodov <amyo...@gmail.com>:

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.

----------
messages: 146434
nosy: amyodov
priority: normal
severity: normal
status: open
title: assert
type: behavior
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13268>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to