From 2ce13dc40ef2d21d49efcfb0d630e3b5c7935273 Mon Sep 17 00:00:00 2001
From: Jean-Marie Traissard <jim@lapin.org>
Date: Fri, 18 Apr 2008 00:02:56 +0000
Subject: [PATCH] http://python.org/dev/peps/pep-0008/ " Comparisons to
 singletons like None should always be done with 'is' or 'is not', never the
 equality operators." Comparisons to None part roster_win.py is NOT checked
 here (waiting for modelfilter)

---
 src/common/GnuPG.py               | 2 +-
 src/common/GnuPGInterface.py      | 6 +++---
 src/common/connection_handlers.py | 2 +-
 src/common/helpers.py             | 2 +-
 src/common/optparser.py           | 2 +-
 src/common/socks5.py              | 8 ++++----
 src/common/stanza_session.py      | 6 +++---
 src/common/xmpp/commands.py       | 4 ++--
 src/common/xmpp/debug.py          | 2 +-
 src/common/xmpp/dispatcher_nb.py  | 2 +-
 src/common/xmpp/roster.py         | 2 +-
 src/dialogs.py                    | 2 +-
 src/gajim.py                      | 8 ++++----
 src/lastfm.py                     | 6 +++---
 src/message_window.py             | 2 +-
 src/remote_control.py             | 2 +-
 16 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/common/GnuPG.py b/src/common/GnuPG.py
index 72c34a8f92..928da7bfc4 100644
--- a/src/common/GnuPG.py
+++ b/src/common/GnuPG.py
@@ -150,7 +150,7 @@ if gajim.HAVE_GPG:
 			return 'BAD_PASSPHRASE'
 
 		def verify(self, str, sign):
-			if str == None:
+			if str is None:
 				return ''
 			f = tmpfile()
 			fd = f.fileno()
diff --git a/src/common/GnuPGInterface.py b/src/common/GnuPGInterface.py
index b86786bb17..90830e5549 100644
--- a/src/common/GnuPGInterface.py
+++ b/src/common/GnuPGInterface.py
@@ -339,9 +339,9 @@ class GnuPG:
         and can be written to.
         """
         
-        if args == None: args = []
-        if create_fhs == None: create_fhs = []
-        if attach_fhs == None: attach_fhs = {}
+        if args is None: args = []
+        if create_fhs is None: create_fhs = []
+        if attach_fhs is None: attach_fhs = {}
         
         for std in _stds:
             if not attach_fhs.has_key(std) \
diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py
index 0011405d28..ee35525eaf 100644
--- a/src/common/connection_handlers.py
+++ b/src/common/connection_handlers.py
@@ -191,7 +191,7 @@ class ConnectionBytestream:
 				ft_add_hosts.append(ft_host)
 		listener = gajim.socks5queue.start_listener(port,
 			sha_str, self._result_socks5_sid, file_props['sid'])
-		if listener == None:
+		if listener is None:
 			file_props['error'] = -5
 			self.dispatch('FILE_REQUEST_ERROR', (unicode(receiver), file_props,
 				''))
diff --git a/src/common/helpers.py b/src/common/helpers.py
index f0f8232ee9..c38e9228eb 100644
--- a/src/common/helpers.py
+++ b/src/common/helpers.py
@@ -644,7 +644,7 @@ def statuses_unified():
 		if not gajim.config.get_per('accounts', account,
 		'sync_with_global_status'):
 			continue
-		if reference == None:
+		if reference is None:
 			reference = gajim.connections[account].connected
 		elif reference != gajim.connections[account].connected:
 			return False
diff --git a/src/common/optparser.py b/src/common/optparser.py
index e4a29eb846..c6952dfc21 100644
--- a/src/common/optparser.py
+++ b/src/common/optparser.py
@@ -83,7 +83,7 @@ class OptionsParser:
 		return True
 
 	def write_line(self, fd, opt, parents, value):
-		if value == None:
+		if value is None:
 			return
 		value = value[1]
 		# convert to utf8 before writing to file if needed
diff --git a/src/common/socks5.py b/src/common/socks5.py
index caa82b6796..3e7feeeb5c 100644
--- a/src/common/socks5.py
+++ b/src/common/socks5.py
@@ -81,7 +81,7 @@ class SocksQueue:
 		and do a socks5 authentication using sid for generated sha
 		'''
 		self.sha_handlers[sha_str] = (sha_handler, sid)
-		if self.listener == None:
+		if self.listener is None:
 			self.listener = Socks5Listener(self.idlequeue, port)
 			self.listener.queue = self
 			self.listener.bind()
@@ -372,7 +372,7 @@ class Socks5:
 		self.file = None
 	
 	def open_file_for_reading(self):
-		if self.file == None:
+		if self.file is None:
 			try:
 				self.file = open(self.file_props['file-name'],'rb')
 				if self.file_props.has_key('offset') and self.file_props['offset']:
@@ -549,7 +549,7 @@ class Socks5:
 			# return number of read bytes. It can be used in progressbar
 		if fd != None:
 			self.file_props['stalled'] = False
-		if fd == None and self.file_props['stalled'] is False:
+		if fd is None and self.file_props['stalled'] is False:
 			return None
 		if self.file_props.has_key('received-len'):
 			if self.file_props['received-len'] != 0:
@@ -1019,7 +1019,7 @@ class Socks5Receiver(Socks5, IdleObject):
 			if version != 0x05 or method == 0xff:
 				self.disconnect()
 		elif self.state == 4: # get approve of our request
-			if buff == None:
+			if buff is None:
 				return None
 			sub_buff = buff[:4]
 			if len(sub_buff) < 4:
diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py
index 84034dc9e8..43faf6a5b3 100644
--- a/src/common/stanza_session.py
+++ b/src/common/stanza_session.py
@@ -226,11 +226,11 @@ class EncryptedStanzaSession(StanzaSession):
 						self.hmac(k, 'Responder SIGMA Key')		)
 
 	def compress(self, plaintext):
-		if self.compression == None:
+		if self.compression is None:
 			return plaintext
 
 	def decompress(self, compressed):
-		if self.compression == None:
+		if self.compression is None:
 			return compressed
 
 	def encrypt(self, encryptable):
@@ -865,7 +865,7 @@ class EncryptedStanzaSession(StanzaSession):
 	def fail_bad_negotiation(self, reason, fields = None):
 		'''sends an error and cancels everything.
 
-if fields == None, the remote party has given us a bad cryptographic value of some kind
+if fields is None, the remote party has given us a bad cryptographic value of some kind
 
 otherwise, list the fields we haven't implemented'''
 
diff --git a/src/common/xmpp/commands.py b/src/common/xmpp/commands.py
index 974d0162dc..673cf894d3 100644
--- a/src/common/xmpp/commands.py
+++ b/src/common/xmpp/commands.py
@@ -227,7 +227,7 @@ class Command_Handler_Prototype(PlugIn):
             action = request.getTagAttr('command','action')
         except:
             action = None
-        if action == None: action = 'execute'
+        if action is None: action = 'execute'
         # Check session is in session list
         if self.sessions.has_key(session):
             if self.sessions[session]['jid']==request.getFrom():
@@ -279,7 +279,7 @@ class TestCommand(Command_Handler_Prototype):
             session = request.getTagAttr('command','sessionid')
         except:
             session = None
-        if session == None:
+        if session is None:
             session = self.getSessionID()
             sessions[session]={'jid':request.getFrom(),'actions':{'cancel':self.cmdCancel,'next':self.cmdSecondStage},'data':{'type':None}}
         # As this is the first stage we only send a form
diff --git a/src/common/xmpp/debug.py b/src/common/xmpp/debug.py
index 9a238aace3..29321c1ff2 100644
--- a/src/common/xmpp/debug.py
+++ b/src/common/xmpp/debug.py
@@ -355,7 +355,7 @@ class Debug:
                 lst2 = self._as_one_list( l )
                 for l2 in lst2: 
                     self._append_unique_str(r, l2 )
-            elif l == None:
+            elif l is None:
                 continue
             else:
                 self._append_unique_str(r, l )
diff --git a/src/common/xmpp/dispatcher_nb.py b/src/common/xmpp/dispatcher_nb.py
index d2ae71dfc0..515a09d10e 100644
--- a/src/common/xmpp/dispatcher_nb.py
+++ b/src/common/xmpp/dispatcher_nb.py
@@ -287,7 +287,7 @@ class Dispatcher(PlugIn):
 
 		if not direct and self._owner._component:
 			if name == 'route':
-				if stanza.getAttr('error') == None:
+				if stanza.getAttr('error') is None:
 					if len(stanza.getChildren()) == 1:
 						stanza = stanza.getChildren()[0]
 						name=stanza.getName()
diff --git a/src/common/xmpp/roster.py b/src/common/xmpp/roster.py
index 33472c56b9..ff64aca5f6 100644
--- a/src/common/xmpp/roster.py
+++ b/src/common/xmpp/roster.py
@@ -65,7 +65,7 @@ class Roster(PlugIn):
         """ Subscription tracker. Used internally for setting items state in
             internal roster representation. """
         sender = stanza.getAttr('from')
-        if not sender == None and not sender.bareMatch(
+        if not sender is None and not sender.bareMatch(
         self._owner.User + '@' + self._owner.Server):
             return
         for item in stanza.getTag('query').getTags('item'):
diff --git a/src/dialogs.py b/src/dialogs.py
index 7b1233b158..9f9bed0dca 100644
--- a/src/dialogs.py
+++ b/src/dialogs.py
@@ -653,7 +653,7 @@ class AddNewContactWindow:
 	def __init__(self, account = None, jid = None, user_nick = None,
 	group = None):
 		self.account = account
-		if account == None:
+		if account is None:
 			# fill accounts with active accounts
 			accounts = []
 			for account in gajim.connections.keys():
diff --git a/src/gajim.py b/src/gajim.py
index 3c9f675441..b513034ef2 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -2166,7 +2166,7 @@ class Interface:
 
 	def handle_event_ping_sent(self, account, contact):
 		ctrl = self.msg_win_mgr.get_control(contact.get_full_jid(), account)
-		if ctrl == None:
+		if ctrl is None:
 			ctrl = self.msg_win_mgr.get_control(contact.jid, account)
 		ctrl.print_conversation(_('Ping?'), 'status')
 
@@ -2174,14 +2174,14 @@ class Interface:
 		contact = data[0]
 		seconds = data[1]
 		ctrl = self.msg_win_mgr.get_control(contact.get_full_jid(), account)
-		if ctrl == None:
+		if ctrl is None:
 			ctrl = self.msg_win_mgr.get_control(contact.jid, account)
 		if ctrl:
 			ctrl.print_conversation(_('Pong! (%s s.)') % seconds, 'status')
 
 	def handle_event_ping_error(self, account, contact):
 		ctrl = self.msg_win_mgr.get_control(contact.get_full_jid(), account)
-		if ctrl == None:
+		if ctrl is None:
 			ctrl = self.msg_win_mgr.get_control(contact.jid, account)
 		if ctrl:
 			ctrl.print_conversation(_('Error.'), 'status')
@@ -2393,7 +2393,7 @@ class Interface:
 					shows[show].append(a)
 		for show in shows:
 			message = self.roster.get_status_message(show)
-			if message == None:
+			if message is None:
 				continue
 			for a in shows[show]:
 				self.roster.send_status(a, show, message)
diff --git a/src/lastfm.py b/src/lastfm.py
index a247ef5a4a..c658a49123 100644
--- a/src/lastfm.py
+++ b/src/lastfm.py
@@ -147,7 +147,7 @@ class LastFM:
 		lst, the Unix time at which a song has been scrobbled, defaults to that
 		of the last song
 		"""
-		if lst == None:
+		if lst is None:
 			lst = self.getLastScrobbledTime()
 		return int(time()) - lst
 
@@ -158,7 +158,7 @@ class LastFM:
 
 		delay, the delay to use, defaults to self.MAX_DELAY
 		"""
-		if delay == None:
+		if delay is None:
 			delay = self.MAX_DELAY
 		return self.timeSinceLastScrobbled() < delay
 
@@ -189,7 +189,7 @@ class LastFM:
 		songTuple, the tuple representing the song, defaults to the last song
 		"""
 		str = ''
-		if songTuple == None:
+		if songTuple is None:
 			songTuple = self.getLastRecentSong()
 
 		if songTuple != None:
diff --git a/src/message_window.py b/src/message_window.py
index eb4c5af6b7..31e070147d 100644
--- a/src/message_window.py
+++ b/src/message_window.py
@@ -547,7 +547,7 @@ class MessageWindow(object):
 		else:
 			page_num = key
 			notebook = self.notebook
-			if page_num == None:
+			if page_num is None:
 				page_num = notebook.get_current_page()
 			nth_child = notebook.get_nth_page(page_num)
 			return self._widget_to_control(nth_child)
diff --git a/src/remote_control.py b/src/remote_control.py
index 8170bc434a..8391de9c3e 100644
--- a/src/remote_control.py
+++ b/src/remote_control.py
@@ -610,7 +610,7 @@ class SignalObject(dbus.service.Object):
 			return None
 		prim_contact = None # primary contact
 		for contact in contacts:
-			if prim_contact == None or contact.priority > prim_contact.priority:
+			if prim_contact is None or contact.priority > prim_contact.priority:
 				prim_contact = contact
 		contact_dict = DBUS_DICT_SV()
 		contact_dict['name'] = DBUS_STRING(prim_contact.name)
-- 
GitLab