mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Replace boolean test with is None.
This commit is contained in:
		
							parent
							
								
									1931ca72b5
								
							
						
					
					
						commit
						f13eb55d59
					
				
					 6 changed files with 10 additions and 10 deletions
				
			
		|  | @ -479,7 +479,7 @@ def close(self): | |||
| def test(args = None): | ||||
|     import sys | ||||
| 
 | ||||
|     if not args: | ||||
|     if args is None: | ||||
|         args = sys.argv[1:] | ||||
| 
 | ||||
|     if args and args[0] == '-s': | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ | |||
| class shlex: | ||||
|     "A lexical analyzer class for simple shell-like syntaxes." | ||||
|     def __init__(self, instream=None, infile=None): | ||||
|         if instream: | ||||
|         if instream is not None: | ||||
|             self.instream = instream | ||||
|             self.infile = infile | ||||
|         else: | ||||
|  | @ -47,7 +47,7 @@ def push_source(self, newstream, newfile=None): | |||
|         self.instream = newstream | ||||
|         self.lineno = 1 | ||||
|         if self.debug: | ||||
|             if newfile: | ||||
|             if newfile is not None: | ||||
|                 print 'shlex: pushing to file %s' % (self.infile,) | ||||
|             else: | ||||
|                 print 'shlex: pushing to stream %s' % (self.instream,) | ||||
|  | @ -188,9 +188,9 @@ def sourcehook(self, newfile): | |||
| 
 | ||||
|     def error_leader(self, infile=None, lineno=None): | ||||
|         "Emit a C-compiler-like, Emacs-friendly error-message leader." | ||||
|         if not infile: | ||||
|         if infile is None: | ||||
|             infile = self.infile | ||||
|         if not lineno: | ||||
|         if lineno is None: | ||||
|             lineno = self.lineno | ||||
|         return "\"%s\", line %d: " % (infile, lineno) | ||||
| 
 | ||||
|  |  | |||
|  | @ -122,7 +122,7 @@ def rmtree(path, ignore_errors=0, onerror=None): | |||
|             exc = sys.exc_info() | ||||
|             if ignore_errors: | ||||
|                 pass | ||||
|             elif onerror: | ||||
|             elif onerror is not None: | ||||
|                 onerror(cmd[0], cmd[1], exc) | ||||
|             else: | ||||
|                 raise exc[0], (exc[1][0], exc[1][1] + ' removing '+cmd[1]) | ||||
|  |  | |||
|  | @ -236,7 +236,7 @@ def __init__(self, host = '', port = 0, local_hostname = None): | |||
|             (code, msg) = self.connect(host, port) | ||||
|             if code != 220: | ||||
|                 raise SMTPConnectError(code, msg) | ||||
|         if local_hostname: | ||||
|         if local_hostname is not None: | ||||
|             self.local_hostname = local_hostname | ||||
|         else: | ||||
|             # RFC 2821 says we should use the fqdn in the EHLO/HELO verb, and | ||||
|  |  | |||
|  | @ -145,7 +145,7 @@ def fixup(literal, flags=flags): | |||
| def _compile_charset(charset, flags, code, fixup=None): | ||||
|     # compile charset subprogram | ||||
|     emit = code.append | ||||
|     if not fixup: | ||||
|     if fixup is None: | ||||
|         fixup = lambda x: x | ||||
|     for op, av in _optimize_charset(charset, fixup): | ||||
|         emit(OPCODES[op]) | ||||
|  |  | |||
|  | @ -80,7 +80,7 @@ def __init__(self): | |||
|     def opengroup(self, name=None): | ||||
|         gid = self.groups | ||||
|         self.groups = gid + 1 | ||||
|         if name: | ||||
|         if name is not None: | ||||
|             ogid = self.groupdict.get(name, None) | ||||
|             if ogid is not None: | ||||
|                 raise error, ("redefinition of group name %s as group %d; " | ||||
|  | @ -97,7 +97,7 @@ class SubPattern: | |||
|     # a subpattern, in intermediate form | ||||
|     def __init__(self, pattern, data=None): | ||||
|         self.pattern = pattern | ||||
|         if not data: | ||||
|         if data is None: | ||||
|             data = [] | ||||
|         self.data = data | ||||
|         self.width = None | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Raymond Hettinger
						Raymond Hettinger