Issue1542997

classification
Title: Fix for Bug #1506561 - assert parameter evaluation
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, raptoraudio
Priority: normal Keywords: patch

Created on 2006-08-19.06:07:58 by raptoraudio, last changed 2006-08-20.20:13:36 by cgroves.

Files
File name Uploaded Description Edit Remove
1506561_assert_fix.diff raptoraudio, 2006-08-19.06:07:58
Messages
msg2531 (view) Author: Raptor Audio (raptoraudio) Date: 2006-08-19.06:07:58
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()
msg2532 (view) Author: Charlie Groves (cgroves) Date: 2006-08-20.20:13:36
Logged In: YES 
user_id=1174327

Looks good to me.  Applied in r2900.
History
Date User Action Args
2006-08-19 06:07:58raptoraudiocreate