Skip to content

Commit f13eb55

Browse files
committed
Replace boolean test with is None.
1 parent 1931ca7 commit f13eb55

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

Lib/sgmllib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def close(self):
479479
def test(args = None):
480480
import sys
481481

482-
if not args:
482+
if args is None:
483483
args = sys.argv[1:]
484484

485485
if args and args[0] == '-s':

Lib/shlex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class shlex:
1313
"A lexical analyzer class for simple shell-like syntaxes."
1414
def __init__(self, instream=None, infile=None):
15-
if instream:
15+
if instream is not None:
1616
self.instream = instream
1717
self.infile = infile
1818
else:
@@ -47,7 +47,7 @@ def push_source(self, newstream, newfile=None):
4747
self.instream = newstream
4848
self.lineno = 1
4949
if self.debug:
50-
if newfile:
50+
if newfile is not None:
5151
print 'shlex: pushing to file %s' % (self.infile,)
5252
else:
5353
print 'shlex: pushing to stream %s' % (self.instream,)
@@ -188,9 +188,9 @@ def sourcehook(self, newfile):
188188

189189
def error_leader(self, infile=None, lineno=None):
190190
"Emit a C-compiler-like, Emacs-friendly error-message leader."
191-
if not infile:
191+
if infile is None:
192192
infile = self.infile
193-
if not lineno:
193+
if lineno is None:
194194
lineno = self.lineno
195195
return "\"%s\", line %d: " % (infile, lineno)
196196

Lib/shutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def rmtree(path, ignore_errors=0, onerror=None):
122122
exc = sys.exc_info()
123123
if ignore_errors:
124124
pass
125-
elif onerror:
125+
elif onerror is not None:
126126
onerror(cmd[0], cmd[1], exc)
127127
else:
128128
raise exc[0], (exc[1][0], exc[1][1] + ' removing '+cmd[1])

Lib/smtplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def __init__(self, host = '', port = 0, local_hostname = None):
236236
(code, msg) = self.connect(host, port)
237237
if code != 220:
238238
raise SMTPConnectError(code, msg)
239-
if local_hostname:
239+
if local_hostname is not None:
240240
self.local_hostname = local_hostname
241241
else:
242242
# RFC 2821 says we should use the fqdn in the EHLO/HELO verb, and

Lib/sre_compile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def fixup(literal, flags=flags):
145145
def _compile_charset(charset, flags, code, fixup=None):
146146
# compile charset subprogram
147147
emit = code.append
148-
if not fixup:
148+
if fixup is None:
149149
fixup = lambda x: x
150150
for op, av in _optimize_charset(charset, fixup):
151151
emit(OPCODES[op])

Lib/sre_parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self):
8080
def opengroup(self, name=None):
8181
gid = self.groups
8282
self.groups = gid + 1
83-
if name:
83+
if name is not None:
8484
ogid = self.groupdict.get(name, None)
8585
if ogid is not None:
8686
raise error, ("redefinition of group name %s as group %d; "
@@ -97,7 +97,7 @@ class SubPattern:
9797
# a subpattern, in intermediate form
9898
def __init__(self, pattern, data=None):
9999
self.pattern = pattern
100-
if not data:
100+
if data is None:
101101
data = []
102102
self.data = data
103103
self.width = None

0 commit comments

Comments
 (0)