]> granicus.if.org Git - python/commitdiff
compare singletons by identity not equality (closes #16712)
authorBenjamin Peterson <benjamin@python.org>
Tue, 9 Oct 2012 15:16:03 +0000 (11:16 -0400)
committerBenjamin Peterson <benjamin@python.org>
Tue, 9 Oct 2012 15:16:03 +0000 (11:16 -0400)
Patch from Serhiy Storchaka.

Lib/os.py
Lib/pydoc.py
Lib/test/support.py
Lib/test/test_ftplib.py
Lib/test/test_posix.py
Lib/test/test_sys.py
Lib/unittest/case.py
Tools/gdb/libpython.py
Tools/scripts/texi2html.py

index 842512a6705f8e8fc332df932372dff2998afe62..84eeaeb524df480b2f2ac066c8ba93f424ef4327 100644 (file)
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -985,7 +985,7 @@ def popen(cmd, mode="r", buffering=-1):
         raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))
     if mode not in ("r", "w"):
         raise ValueError("invalid mode %r" % mode)
-    if buffering == 0 or buffering == None:
+    if buffering == 0 or buffering is None:
         raise ValueError("popen() does not support unbuffered streams")
     import subprocess, io
     if mode == "r":
index aa296c4c790465eb35dc1764bbe53df64bfd413c..fa531e90514eb2ab27a3e4fd7eb19a8b6a64c2fd 100755 (executable)
@@ -2551,8 +2551,8 @@ def cli():
             if opt == '-w':
                 writing = True
 
-        if start_server == True:
-            if port == None:
+        if start_server:
+            if port is None:
                 port = 0
             browse(port, open_browser=open_browser)
             return
index 014bcf57c0ef947b52f9d825ece1cdcef02b9434..c5640e0a087bfc8884f66d46d4abd72915ece6ad 100644 (file)
@@ -1232,7 +1232,7 @@ def run_with_tz(tz):
             try:
                 return func(*args, **kwds)
             finally:
-                if orig_tz == None:
+                if orig_tz is None:
                     del os.environ['TZ']
                 else:
                     os.environ['TZ'] = orig_tz
index 7028f465199410b4f068e514405ad40dfeb7a589..299a146991675c47edcbd2f7fa0502d70dbdba70 100644 (file)
@@ -342,7 +342,7 @@ if ssl is not None:
                 # http://www.mail-archive.com/openssl-users@openssl.org/msg60710.html
                 pass
             self._ssl_closing = False
-            if getattr(self, '_ccc', False) == False:
+            if getattr(self, '_ccc', False) is False:
                 super(SSLConnection, self).close()
             else:
                 pass
index 4e7a37c8585f6f142ebed52c684c635890c5f41a..f59607b4f53da9ca9a6729f66cc1ef57c0c6a2e8 100644 (file)
@@ -651,7 +651,7 @@ class PosixTester(unittest.TestCase):
             groups = idg.read().strip()
             ret = idg.close()
 
-        if ret != None or not groups:
+        if ret is not None or not groups:
             raise unittest.SkipTest("need working 'id -G'")
 
         self.assertEqual(
@@ -665,7 +665,7 @@ class PosixTester(unittest.TestCase):
             groups = idg.read().strip()
             ret = idg.close()
 
-        if ret != None or not groups:
+        if ret is not None or not groups:
             raise unittest.SkipTest("need working 'id -G'")
 
         # 'id -G' and 'os.getgroups()' should return the same
index 6e0c6eef31967347477e436526f814f89d36ab89..e5ec85c488b31780d93e0fe82e04e5743c1ae1d4 100644 (file)
@@ -897,7 +897,7 @@ class SizeofTest(unittest.TestCase):
         except TypeError:
             tb = sys.exc_info()[2]
             # traceback
-            if tb != None:
+            if tb is not None:
                 check(tb, size('2P2i'))
         # symtable entry
         # XXX
index 28f0a2d141045bace50a50226177638d90ff94b5..f33486543feeb2ef1737a07554d5871dc1b3564f 100644 (file)
@@ -736,7 +736,7 @@ class TestCase(object):
             msg: Optional message to use on failure instead of a list of
                     differences.
         """
-        if seq_type != None:
+        if seq_type is not None:
             seq_type_name = seq_type.__name__
             if not isinstance(seq1, seq_type):
                 raise self.failureException('First sequence is not a %s: %s'
index 2cdc3da8e92a1c354e70fa64f5a5025207280459..368a7d57fc800e2b43a3c0d80efc395fe8962aed 100644 (file)
@@ -1332,7 +1332,7 @@ that this python file is installed to the same path as the library (or its
   /usr/lib/debug/usr/lib/libpython2.6.so.1.0.debug-gdb.py
 """
 def register (obj):
-    if obj == None:
+    if obj is None:
         obj = gdb
 
     # Wire up the pretty-printer
index af2147a76bbfe579af73c3d5b18c37164891a998..99835280fe7a97e20ff8a4ff94bbd7dbf841dad2 100755 (executable)
@@ -319,7 +319,7 @@ class TexinfoParser:
 
     # Start saving text in a buffer instead of writing it to a file
     def startsaving(self):
-        if self.savetext != None:
+        if self.savetext is not None:
             self.savestack.append(self.savetext)
             # print '*** Recursively saving text, expect trouble'
         self.savetext = ''
@@ -341,7 +341,7 @@ class TexinfoParser:
         except:
             print(args)
             raise TypeError
-        if self.savetext != None:
+        if self.savetext is not None:
             self.savetext = self.savetext + text
         elif self.nodefp:
             self.nodefp.write(text)
@@ -350,7 +350,7 @@ class TexinfoParser:
 
     # Complete the current node -- write footnotes and close file
     def endnode(self):
-        if self.savetext != None:
+        if self.savetext is not None:
             print('*** Still saving text at end of node')
             dummy = self.collectsavings()
         if self.footnotes:
@@ -804,7 +804,7 @@ class TexinfoParser:
     def close_i(self): self.write('</I>')
 
     def open_footnote(self):
-        # if self.savetext <> None:
+        # if self.savetext is not None:
         #       print '*** Recursive footnote -- expect weirdness'
         id = len(self.footnotes) + 1
         self.write(self.FN_SOURCE_PATTERN % {'id': repr(id)})
@@ -1442,7 +1442,7 @@ class TexinfoParser:
             else:
                 # some other character, e.g. '-'
                 args = self.itemarg + ' ' + args
-        if self.itemnumber != None:
+        if self.itemnumber is not None:
             args = self.itemnumber + '. ' + args
             self.itemnumber = increment(self.itemnumber)
         if self.stack and self.stack[-1] == 'table':