[MERGE] remove has_key() usage

Robey Pointer robey at lag.net
Sat Sep 9 07:36:30 BST 2006


On 7 Sep 2006, at 19:56, Martin Pool wrote:

> On  7 Sep 2006, Robey Pointer <robey at lag.net> wrote:
>>> None is a singleton, and "is" is faster than '=='.
>>
>> Mine too.  That's how I've usually done it in the past.
>>
>> But recently, pychecker started complaining about me using 'is'.  It
>> says:
>>
>> 	Using is None, may not always work
>>
>> So what's that all about?  "May not always work"?  That sounds pretty
>> serious.  Anyone know?
>
> It's a dumb bug in pychecker.  I'm told there will be a fix but  
> it's not
> released yet.
>
> The general rule is that 'is' to a constant is dangerous, e.g.
>
>   name is 'martin'
>
> may break if Python's rules for interning strings change.  However,
> there is by definition only one None, so 'is' is safe.  We should use
> 'is None', and grep out the pychecker warnings.
>
> We recently added Makefile targets to run pyflakes, which gives other
> useful warnings, though I think not a strict superset of pychecker.

Okay, so pychecker can bite me. :)  I reverted all the '== None'  
stuff to 'is None' and pushed it to the same branch:

     http://www.lag.net/~robey/code/bzr.dev.no_has_key/

robey





More information about the bazaar mailing list