[issue2503] Replace == None/True/False with is

2008-03-29 Thread Wummel

Wummel [EMAIL PROTECTED] added the comment:

Here is an updated patch, using is False to be consistent, and also
replacing the != occurences.

Added file: 
http://bugs.python.org/file9886/0001-Replace-None-True-False-with-is.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-29 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

This patch is fine.

Before applying, check the code in PyShell to see if the if response 
is False line can be simplified to if not response.

--
nosy: +rhettinger
resolution:  - accepted

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-29 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

Benjamin, do you want to apply this? Add a Misc/NEWS item as well.

--
assignee:  - benjamin.peterson
nosy: +benjamin.peterson

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-29 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

Don't think changes like this warrant a NEWS entry.  It's a code clean-
up, not a semantic change.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-29 Thread Benjamin Peterson

Benjamin Peterson [EMAIL PROTECTED] added the comment:

Patch was committed in r62043. Wummel, thanks for the patch! Georg,
thanks for the practice.

--
status: open - closed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-28 Thread Wummel

New submission from Wummel [EMAIL PROTECTED]:

Test equality with None/True/False singletons should be done
by is rather than == to be on the safe side. Otherwise
objects overriding __eq__ could compare equal to one of those
singletons.

--
components: None
files: 0001-Replace-None-True-False-with-is.patch
keywords: patch
messages: 64628
nosy: calvin
severity: normal
status: open
title: Replace == None/True/False with is
versions: Python 2.6
Added file: 
http://bugs.python.org/file9882/0001-Replace-None-True-False-with-is.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-28 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:

You are right of course, but just out of curiosity, do you really have
objects that compare equal to None?

--
nosy: +amaury.forgeotdarc

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-28 Thread Georg Brandl

Georg Brandl [EMAIL PROTECTED] added the comment:

I'm in favor of this patch. Not only is is faster here, but it is also
way more idiomatic.

--
nosy: +georg.brandl

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-28 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc [EMAIL PROTECTED] added the comment:

Yes, PEP8 says::

Comparisons to singletons like None should always be done with
'is' or 'is not', never the equality operators.

Reading the patch:
- a change modifies x == False into not x, another moves some lines.
I checked that they are OK (x is already the result of a comparison).
- some occurrences of x != None are not replaced. Why? (ex. in
test_ast.py)

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2503] Replace == None/True/False with is

2008-03-28 Thread Wummel

Wummel [EMAIL PROTECTED] added the comment:

Amaury, I never saw an object comparing equal to None.
I think the most likely case is a buggy x.__eq__() implementation. Then
the if x == None statement gets triggered, and somebody has a hard
time with bug hunting.

Just a note: I used an adapted source checker for this patch, which
initially came from the Sphinx documentation project, found under
tools/check_sources.py. So the credits for this go to Georg Brandl.

That is also why '!=' did not get replaced (the source checker only
searched for '=='. I will post an updated patch.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2503
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com