[Python-Dev] Compiler treats None both as a constant and variable
Guido van Rossum
guido@python.org
Sun, 30 Mar 2003 14:02:38 -0500
Sun, 30 Mar 2003 14:02:38 -0500
- Previous message: [Python-Dev] Compiler treats None both as a constant and variable
- Next message: [Python-Dev] Weekly Python Bug/Patch Summary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> >>> def f(): > None > > >>> dis(f) > 2 0 LOAD_GLOBAL 0 (None) > 3 POP_TOP > 4 LOAD_CONST 0 (None) > 7 RETURN_VALUE > > >>> None = 1 > <stdin>:1: SyntaxWarning: assignment to None > >>> f() == None > False > > > Is this a bug? Yes, assigning to None is a bug. :-) > Should the compiler use the GLOBAL in both places? No, not until we've officially changed the rules. > Or, is it reasonable to use CONST in both places? No, not until assigning to None is an error rather than a warning. This will have to wait until at least 2.4 -- the warning is new in 2.3. --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Compiler treats None both as a constant and variable
- Next message: [Python-Dev] Weekly Python Bug/Patch Summary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]