-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contracts does not stop execution immediately having found an unexpected OR null input #65
Comments
Hi again. After getting deeper into python and learning that #!/usr/bin/python3
# -*- coding: utf8 -*-
from contracts import contract
class ObjectThatWillSeeDeathBeforeBeingBorn(object):
@contract
def __init__(self, TestingString: 'str[>0]'):
print('String given as parameter: %s.' % TestingString)
print('ID of ObjectThatWillSeeDeathBeforeBeingBorn: %s.' % id(self))
def __enter__(self):
pass
def __exit__(self, type, value, tb):
print('ID of object being killed: %s.' % id(self))
with ObjectThatWillSeeDeathBeforeBeingBorn() as NewObjectForTestingTheBug:
pass we now get:
Please note, that code in Lets try initating the object with a wrong type: Result:
Now let's try with the correct type: Result:
So the lesson here is not to use |
Hi.
I think I have stumbled upon a bug or if not a bug then atleast an counterintuitive feature.
Consider the following code:
When executed as listed above we will get this as output:
The notable thing here is that we don't get any output from init but we do get output from del.
If we modify the last line so it looks like this:
NewObjectForTestingTheBug = ObjectThatWillSeeDeathBeforeBeingBorn(42)
the output looks like this:
I had expected that when a breach of contract has been found everything grinds to a halt but we can see that in both cases code still gets executed.
Last but not least, thank You for Your great work on contracts!
The text was updated successfully, but these errors were encountered: