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]
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
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
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
__
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
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:
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]
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
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
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
10 matches
Mail list logo