[issue22574] super() and del in the same method leads to UnboundLocalError

2014-10-07 Thread Pierre-Antoine BRAMERET
Pierre-Antoine BRAMERET added the comment: Hi, Tanks for your clear answer. I find it surprising that "del" bounds the name locally, but with little more thinking, it is not... -- resolution: -> not a bug status: open -> closed ___ Python tracker

[issue22574] super() and del in the same method leads to UnboundLocalError

2014-10-07 Thread Mark Dickinson
Mark Dickinson added the comment: So while the behaviour is surprising, the language is behaving as designed: the target of `del` is considered to be a local variable for the entire function definition. (In much the same way, the targets of simple assignments are considered local, so if you'

[issue22574] super() and del in the same method leads to UnboundLocalError

2014-10-07 Thread Pierre-Antoine BRAMERET
Pierre-Antoine BRAMERET added the comment: Sorry, I miscopied the last Traceback. Please find the following: Traceback (most recent call last): File "", line 1, in File "", line 4, in __init__ assert Foo UnboundLocalError: local variable 'Foo' referenced before assignment -- _

[issue22574] super() and del in the same method leads to UnboundLocalError

2014-10-07 Thread Pierre-Antoine BRAMERET
New submission from Pierre-Antoine BRAMERET: Hi, With the following code: class Base(object): pass class Foo(Base): def __init__(self): super(Foo,self).__init__() if False: del Foo I expect that Foo() would give me a Foo instance. Instead, it raises the following exception: