Skip to content

Commit eed62fe

Browse files
author
benjamin.peterson
committed
#2503 make singletons compared with "is" not == or !=
Thanks to Wummel for the patch git-svn-id: http://svn.python.org/projects/python/trunk@62043 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 4a0ae2b commit eed62fe

54 files changed

Lines changed: 140 additions & 141 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Demo/classes/Dbm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test():
5050
value = d[key]
5151
print 'currently:', value
5252
value = input('value: ')
53-
if value == None:
53+
if value is None:
5454
del d[key]
5555
else:
5656
d[key] = value

Demo/curses/ncurses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from curses import panel
1010

1111
def wGetchar(win = None):
12-
if win == None: win = stdscr
12+
if win is None: win = stdscr
1313
return win.getch()
1414

1515
def Getchar():

Demo/rpc/mountclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def bindsocket(self):
100100
# This function is called to cough up a suitable
101101
# authentication object for a call to procedure 'proc'.
102102
def mkcred(self):
103-
if self.cred == None:
103+
if self.cred is None:
104104
self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default()
105105
return self.cred
106106

Demo/rpc/nfsclient.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def addpackers(self):
129129
self.unpacker = NFSUnpacker('')
130130

131131
def mkcred(self):
132-
if self.cred == None:
132+
if self.cred is None:
133133
self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default()
134134
return self.cred
135135

@@ -170,7 +170,7 @@ def Listdir(self, dir):
170170
for fileid, name, cookie in entries:
171171
list.append((fileid, name))
172172
last_cookie = cookie
173-
if eof or last_cookie == None:
173+
if eof or last_cookie is None:
174174
break
175175
ra = (ra[0], last_cookie, ra[2])
176176
return list
@@ -184,7 +184,7 @@ def test():
184184
else: filesys = None
185185
from mountclient import UDPMountClient, TCPMountClient
186186
mcl = TCPMountClient(host)
187-
if filesys == None:
187+
if filesys is None:
188188
list = mcl.Export()
189189
for item in list:
190190
print item

Demo/rpc/rpc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,13 @@ def do_call(self):
264264

265265
def mkcred(self):
266266
# Override this to use more powerful credentials
267-
if self.cred == None:
267+
if self.cred is None:
268268
self.cred = (AUTH_NULL, make_auth_null())
269269
return self.cred
270270

271271
def mkverf(self):
272272
# Override this to use a more powerful verifier
273-
if self.verf == None:
273+
if self.verf is None:
274274
self.verf = (AUTH_NULL, make_auth_null())
275275
return self.verf
276276

@@ -321,7 +321,7 @@ def recvrecord(sock):
321321
def bindresvport(sock, host):
322322
global last_resv_port_tried
323323
FIRST, LAST = 600, 1024 # Range of ports to try
324-
if last_resv_port_tried == None:
324+
if last_resv_port_tried is None:
325325
import os
326326
last_resv_port_tried = FIRST + os.getpid() % (LAST-FIRST)
327327
for i in range(last_resv_port_tried, LAST) + \
@@ -814,7 +814,7 @@ def loop(self):
814814
def session(self):
815815
call, host_port = self.sock.recvfrom(8192)
816816
reply = self.handle(call)
817-
if reply != None:
817+
if reply is not None:
818818
self.sock.sendto(reply, host_port)
819819

820820

Demo/tkinter/guido/paint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def b1up(event):
5050
def motion(event):
5151
if b1 == "down":
5252
global xold, yold
53-
if xold != None and yold != None:
53+
if xold is not None and yold is not None:
5454
event.widget.create_line(xold,yold,event.x,event.y,smooth=TRUE)
5555
# here's where you draw it. smooth. neat.
5656
xold = event.x

Lib/bsddb/dbshelve.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __delitem__(self, key):
133133

134134

135135
def keys(self, txn=None):
136-
if txn != None:
136+
if txn is not None:
137137
return self.db.keys(txn)
138138
else:
139139
return self.db.keys()
@@ -157,7 +157,7 @@ def __repr__(self):
157157

158158

159159
def items(self, txn=None):
160-
if txn != None:
160+
if txn is not None:
161161
items = self.db.items(txn)
162162
else:
163163
items = self.db.items()
@@ -168,7 +168,7 @@ def items(self, txn=None):
168168
return newitems
169169

170170
def values(self, txn=None):
171-
if txn != None:
171+
if txn is not None:
172172
values = self.db.values(txn)
173173
else:
174174
values = self.db.values()

Lib/bsddb/test/test_basics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
363363
else:
364364
if set_raises_error:
365365
self.fail("expected exception")
366-
if n != None:
366+
if n is not None:
367367
self.fail("expected None: %r" % (n,))
368368

369369
rec = c.get_both('0404', self.makeData('0404'))
@@ -377,7 +377,7 @@ def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
377377
else:
378378
if get_raises_error:
379379
self.fail("expected exception")
380-
if n != None:
380+
if n is not None:
381381
self.fail("expected None: %r" % (n,))
382382

383383
if self.d.get_type() == db.DB_BTREE:

Lib/bsddb/test/test_dbtables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def test_Modify(self):
323323
self.tdb.Insert(tabname, {'Type': 'Unknown', 'Access': '0'})
324324

325325
def set_type(type):
326-
if type == None:
326+
if type is None:
327327
return 'MP3'
328328
return type
329329

Lib/idlelib/AutoComplete.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ class AutoComplete:
3535
"popupwait", type="int", default=0)
3636

3737
def __init__(self, editwin=None):
38-
if editwin == None: # subprocess and test
39-
self.editwin = None
40-
return
4138
self.editwin = editwin
39+
if editwin is None: # subprocess and test
40+
return
4241
self.text = editwin.text
4342
self.autocompletewindow = None
4443

0 commit comments

Comments
 (0)