The following code (not directly in an interpreter, but execute as file)
def top(deck):
pass
def b():
global deck
produces the error
SyntaxError: name 'deck' is local and global
on python2.6.4 and
SyntaxError: name 'deck' is parameter and global
on python 3.1
python2.4 seems to accept this code, so does the 2.6.4 interactive interpreter.
This is already odd; why is 'deck' conflicting if it's a global in one method and a parameter in the other?
But it gets weirder. Rename 'top' to basically anything else, and the problem disappears.
Can someone explain this behaviour? I feel like I'm missing something very obvious here. Is the name 'top' somehow affecting certain scoping internals?
Update
This indeed appears to be a bug in the python core. I have filed a bug report.