]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.10] bpo-45060: Get rid of few uses of the equality operators with None (GH-28087...
authorSerhiy Storchaka <storchaka@gmail.com>
Sat, 4 Sep 2021 01:13:00 +0000 (04:13 +0300)
committerGitHub <noreply@github.com>
Sat, 4 Sep 2021 01:13:00 +0000 (21:13 -0400)
(cherry picked from commit 3c65457156d87e55010507d616b4eecb7a02883d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Doc/library/dbm.rst
Lib/ctypes/_aix.py
Lib/email/contentmanager.py
Lib/test/datetimetester.py
Lib/test/test_pty.py
Lib/test/test_type_annotations.py
Modules/_gdbmmodule.c
Modules/clinic/_gdbmmodule.c.h
Tools/clinic/clinic.py

index 57ae547b833cc0eb2a76cdfc4ed3d1f5d5b24794..ff01ae90f642573aa24f86528423caa59902d4ab 100644 (file)
@@ -216,7 +216,7 @@ supported.
       contains them all::
 
          k = db.firstkey()
-         while k != None:
+         while k is not None:
              print(k)
              k = db.nextkey(k)
 
index 190cac6507edef91be37691be81882e5a63688f4..26959d90a4dd6a05424ea5c5af4c935b8f3291fb 100644 (file)
@@ -282,7 +282,7 @@ def find_shared(paths, name):
         if path.exists(archive):
             members = get_shared(get_ld_headers(archive))
             member = get_member(re.escape(name), members)
-            if member != None:
+            if member is not None:
                 return (base, member)
             else:
                 return (None, None)
@@ -307,7 +307,7 @@ def find_library(name):
 
     libpaths = get_libpaths()
     (base, member) = find_shared(libpaths, name)
-    if base != None:
+    if base is not None:
         return f"{base}({member})"
 
     # To get here, a member in an archive has not been found
index 3cf62dc8621cd9da3f0a49de740fca1d88c887e8..fcf278dbccbac9581e4de5cad5e2de252a2e4d4a 100644 (file)
@@ -144,7 +144,7 @@ def _encode_text(string, charset, cte, policy):
     linesep = policy.linesep.encode('ascii')
     def embedded_body(lines): return linesep.join(lines) + linesep
     def normal_body(lines): return b'\n'.join(lines) + b'\n'
-    if cte==None:
+    if cte is None:
         # Use heuristics to decide on the "best" encoding.
         if max((len(x) for x in lines), default=0) <= policy.max_line_length:
             try:
index 316cf0b8da7b488943987218ffc1a699f990c4ba..6414f1ace3fed31807c6ae62d2dee110477bd7f7 100644 (file)
@@ -344,7 +344,7 @@ class TestTimeZone(unittest.TestCase):
         with self.assertRaises(TypeError): timezone(ZERO) < timezone(ZERO)
         self.assertIn(timezone(ZERO), {timezone(ZERO)})
         self.assertTrue(timezone(ZERO) != None)
-        self.assertFalse(timezone(ZERO) ==  None)
+        self.assertFalse(timezone(ZERO) == None)
 
         tz = timezone(ZERO)
         self.assertTrue(tz == ALWAYS_EQ)
index e2e9475b5d337db8d19009a837a9b715b43063f9..0c178127571b07c8310de09c52306b2ea8da5466 100644 (file)
@@ -136,7 +136,7 @@ class PtyTest(unittest.TestCase):
             mode = None
 
         new_stdin_winsz = None
-        if self.stdin_rows != None and self.stdin_cols != None:
+        if self.stdin_rows is not None and self.stdin_cols is not None:
             try:
                 # Modify pty.STDIN_FILENO window size; we need to
                 # check if pty.openpty() is able to set pty slave
index f6c99bda3aa6f6989b4695a1f6ed7739fd689d53..87f46c2ce8ce616ff00d07085b09dad36ba2190e 100644 (file)
@@ -71,7 +71,7 @@ class TypeAnnotationTests(unittest.TestCase):
 
             @__annotations__.deleter
             def __annotations__(self):
-                if hasattr(self, 'my_annotations') and self.my_annotations == None:
+                if getattr(self, 'my_annotations', False) is None:
                     raise AttributeError('__annotations__')
                 self.my_annotations = None
 
index 6ca3ed6cc36fcc7b99389e02828d9a6043a649e5..a7fb6a33c862c4be5056f08d72d2ab14efcee2b3 100644 (file)
@@ -450,7 +450,7 @@ The following code prints every key in the database db, without having
 to create a list in memory that contains them all:
 
       k = db.firstkey()
-      while k != None:
+      while k is not None:
           print(k)
           k = db.nextkey(k)
 [clinic start generated code]*/
@@ -458,7 +458,7 @@ to create a list in memory that contains them all:
 static PyObject *
 _gdbm_gdbm_nextkey_impl(gdbmobject *self, PyTypeObject *cls, const char *key,
                         Py_ssize_clean_t key_length)
-/*[clinic end generated code: output=204964441fdbaf02 input=fcf6a51a96ce0172]*/
+/*[clinic end generated code: output=204964441fdbaf02 input=365e297bc0b3db48]*/
 {
     PyObject *v;
     datum dbm_key, nextkey;
index ffd2179f36970adcd6bd94f8fdb3be1e786c56a8..ea4ee7df001c181268ba80d53089456d2f50c9df 100644 (file)
@@ -161,7 +161,7 @@ PyDoc_STRVAR(_gdbm_gdbm_nextkey__doc__,
 "to create a list in memory that contains them all:\n"
 "\n"
 "      k = db.firstkey()\n"
-"      while k != None:\n"
+"      while k is not None:\n"
 "          print(k)\n"
 "          k = db.nextkey(k)");
 
@@ -340,4 +340,4 @@ skip_optional:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=e84bc6ac82fcb6d4 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3b88446433e43d96 input=a9049054013a1b77]*/
index 959742677d2f6794eeb02df3f14877bf3e41aacf..969008ade9790ff31b658d38dd9fed161b4face8 100755 (executable)
@@ -1632,7 +1632,7 @@ class BlockPrinter:
         dsl_name = block.dsl_name
         write = self.f.write
 
-        assert not ((dsl_name == None) ^ (output == None)), "you must specify dsl_name and output together, dsl_name " + repr(dsl_name)
+        assert not ((dsl_name is None) ^ (output is None)), "you must specify dsl_name and output together, dsl_name " + repr(dsl_name)
 
         if not dsl_name:
             write(input)
@@ -2931,7 +2931,7 @@ class int_converter(CConverter):
             self.format_unit = 'C'
         elif accept != {int}:
             fail("int_converter: illegal 'accept' argument " + repr(accept))
-        if type != None:
+        if type is not None:
             self.type = type
 
     def parse_arg(self, argname, displayname):