mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
bpo-45060: Get rid of few uses of the equality operators with None (GH-28087)
This commit is contained in:
parent
08767c73b5
commit
3c65457156
9 changed files with 13 additions and 13 deletions
|
@ -216,7 +216,7 @@ supported.
|
||||||
contains them all::
|
contains them all::
|
||||||
|
|
||||||
k = db.firstkey()
|
k = db.firstkey()
|
||||||
while k != None:
|
while k is not None:
|
||||||
print(k)
|
print(k)
|
||||||
k = db.nextkey(k)
|
k = db.nextkey(k)
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ def find_shared(paths, name):
|
||||||
if path.exists(archive):
|
if path.exists(archive):
|
||||||
members = get_shared(get_ld_headers(archive))
|
members = get_shared(get_ld_headers(archive))
|
||||||
member = get_member(re.escape(name), members)
|
member = get_member(re.escape(name), members)
|
||||||
if member != None:
|
if member is not None:
|
||||||
return (base, member)
|
return (base, member)
|
||||||
else:
|
else:
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
@ -307,7 +307,7 @@ def find_library(name):
|
||||||
|
|
||||||
libpaths = get_libpaths()
|
libpaths = get_libpaths()
|
||||||
(base, member) = find_shared(libpaths, name)
|
(base, member) = find_shared(libpaths, name)
|
||||||
if base != None:
|
if base is not None:
|
||||||
return f"{base}({member})"
|
return f"{base}({member})"
|
||||||
|
|
||||||
# To get here, a member in an archive has not been found
|
# To get here, a member in an archive has not been found
|
||||||
|
|
|
@ -144,7 +144,7 @@ def _encode_text(string, charset, cte, policy):
|
||||||
linesep = policy.linesep.encode('ascii')
|
linesep = policy.linesep.encode('ascii')
|
||||||
def embedded_body(lines): return linesep.join(lines) + linesep
|
def embedded_body(lines): return linesep.join(lines) + linesep
|
||||||
def normal_body(lines): return b'\n'.join(lines) + b'\n'
|
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.
|
# Use heuristics to decide on the "best" encoding.
|
||||||
if max((len(x) for x in lines), default=0) <= policy.max_line_length:
|
if max((len(x) for x in lines), default=0) <= policy.max_line_length:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -136,7 +136,7 @@ class PtyTest(unittest.TestCase):
|
||||||
mode = None
|
mode = None
|
||||||
|
|
||||||
new_stdin_winsz = 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:
|
try:
|
||||||
# Modify pty.STDIN_FILENO window size; we need to
|
# Modify pty.STDIN_FILENO window size; we need to
|
||||||
# check if pty.openpty() is able to set pty slave
|
# check if pty.openpty() is able to set pty slave
|
||||||
|
|
|
@ -71,7 +71,7 @@ class TypeAnnotationTests(unittest.TestCase):
|
||||||
|
|
||||||
@__annotations__.deleter
|
@__annotations__.deleter
|
||||||
def __annotations__(self):
|
def __annotations__(self):
|
||||||
if hasattr(self, 'my_annotations') and self.my_annotations == None:
|
if getattr(self, 'my_annotations', False) is None:
|
||||||
raise AttributeError('__annotations__')
|
raise AttributeError('__annotations__')
|
||||||
self.my_annotations = None
|
self.my_annotations = None
|
||||||
|
|
||||||
|
|
|
@ -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:
|
to create a list in memory that contains them all:
|
||||||
|
|
||||||
k = db.firstkey()
|
k = db.firstkey()
|
||||||
while k != None:
|
while k is not None:
|
||||||
print(k)
|
print(k)
|
||||||
k = db.nextkey(k)
|
k = db.nextkey(k)
|
||||||
[clinic start generated code]*/
|
[clinic start generated code]*/
|
||||||
|
@ -458,7 +458,7 @@ to create a list in memory that contains them all:
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_gdbm_gdbm_nextkey_impl(gdbmobject *self, PyTypeObject *cls, const char *key,
|
_gdbm_gdbm_nextkey_impl(gdbmobject *self, PyTypeObject *cls, const char *key,
|
||||||
Py_ssize_t key_length)
|
Py_ssize_t key_length)
|
||||||
/*[clinic end generated code: output=c81a69300ef41766 input=fcf6a51a96ce0172]*/
|
/*[clinic end generated code: output=c81a69300ef41766 input=365e297bc0b3db48]*/
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
datum dbm_key, nextkey;
|
datum dbm_key, nextkey;
|
||||||
|
|
4
Modules/clinic/_gdbmmodule.c.h
generated
4
Modules/clinic/_gdbmmodule.c.h
generated
|
@ -161,7 +161,7 @@ PyDoc_STRVAR(_gdbm_gdbm_nextkey__doc__,
|
||||||
"to create a list in memory that contains them all:\n"
|
"to create a list in memory that contains them all:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" k = db.firstkey()\n"
|
" k = db.firstkey()\n"
|
||||||
" while k != None:\n"
|
" while k is not None:\n"
|
||||||
" print(k)\n"
|
" print(k)\n"
|
||||||
" k = db.nextkey(k)");
|
" k = db.nextkey(k)");
|
||||||
|
|
||||||
|
@ -340,4 +340,4 @@ skip_optional:
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=c3ee3ad64a2f331f input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=1fed9ed50ad23551 input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -1691,7 +1691,7 @@ class BlockPrinter:
|
||||||
dsl_name = block.dsl_name
|
dsl_name = block.dsl_name
|
||||||
write = self.f.write
|
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:
|
if not dsl_name:
|
||||||
write(input)
|
write(input)
|
||||||
|
@ -3003,7 +3003,7 @@ class int_converter(CConverter):
|
||||||
self.format_unit = 'C'
|
self.format_unit = 'C'
|
||||||
elif accept != {int}:
|
elif accept != {int}:
|
||||||
fail("int_converter: illegal 'accept' argument " + repr(accept))
|
fail("int_converter: illegal 'accept' argument " + repr(accept))
|
||||||
if type != None:
|
if type is not None:
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
||||||
def parse_arg(self, argname, displayname):
|
def parse_arg(self, argname, displayname):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue