Close off the "Verre Carlo hack" as discussed on python-dev.

This commit is contained in:
Guido van Rossum 2003-04-14 21:46:03 +00:00
parent 2fd02eb80f
commit 4dcdb78c6f
2 changed files with 39 additions and 0 deletions

View file

@ -3840,6 +3840,22 @@ def proxysuper():
p = Proxy(obj)
vereq(C.__dict__["f"](p), "B.f->C.f")
def verrecarlo():
if verbose:
print "Testing prohibition of Verre Carlo's hack..."
try:
object.__setattr__(str, "foo", 42)
except TypeError:
pass
else:
raise TestFailed, "Verre Carlo __setattr__ suceeded!"
try:
object.__delattr__(str, "lower")
except TypeError:
pass
else:
raise TestFailed, "Verre Carlo __delattr__ succeeded!"
def test_main():
do_this_first()
@ -3929,6 +3945,7 @@ def test_main():
meth_class_get()
isinst_isclass()
proxysuper()
verrecarlo()
if verbose: print "All OK"