[Python-Dev] Constancy of None

Raymond Hettinger python at rcn.com
Fri Jul 16 11:47:05 CEST 2004

> > That raises the question.  Since there was a SyntaxWarning in Py2.3,
> > should it have been escalated to an error for Py2.4?

> > +1.
> >
> > (And is it time to make assignments to True and False trigger a
> > SyntaxWarning, or should that wait until 2.5?)

> We should be much more conservative with that.  There's tons of code
> out there that assigns these (conditionally, if it's 2.3-aware) to
> truth values and we don't want to break that.

We may never (prior to Py3.0) be able to block assignments to
True/False; however, some lesser restriction could be feasible.  For
example, it may be possible to require that the assignment have the same
boolean value so that "True=x" rejects when bool(x)!=True.  The would
allow "True=1" and
"True=(1==1)" statements to work while still enabling the compiler to
optimize the test out of "while True".

While I'm not sure this is a great idea, I would have no remorse for
wrecking a piece of code that assigned "True=0"    ;-)

>  The situation with None
> is much better, since it was always there; AFAIK only a few speed
> freaks in Zope-land have ever assigned to it (and always using the
> form "None = None").

Guido's reasoning here is confirmed by Py2.3's SyntaxWarning not causing
the slightest stir.  With respect to the constancy of None, we are on
firm ground.

If there are no objections, I would like to leave in yesterday's patch
and upgrade the Py2.4 None assignment SyntaxWarning to a SyntaxError.


More information about the Python-Dev mailing list