Message2531

Author raptoraudio
Recipients
Date 2006-08-19.06:07:58
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Problem: Assertions process the message node, if passed
regardless of whether the assertion is true or false.
This behavior is not consistent with CPython.

Fix: Changed the visitAssert method to only reach the
message, if the assertion fails. Calling the Py.assert_
method was changed to compare the assertion result
after visit(node.test). If the assertion succeeds, then the
generated code will branch to the end of the method.
Otherwise, the node.msg will be processed and an
AssertionError will be raised.

Test: Below is some sample code. The code used to run
the method regardless of the assertion. The new method
will only run it if the assert fails.

def f():
    print "Should only print when assert fails!"
    return 1

assert 1, f()
assert 0, f()
History
Date User Action Args
2008-02-20 17:18:34adminlinkissue1542997 messages
2008-02-20 17:18:34admincreate