mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	This patch changes a few of the scripts to have __name__=='__main__' clauses so that they are importable without running. Also fixes the syntax errors revealed by the tests.
This commit is contained in:
		
						commit
						ce9806215b
					
				
					 7 changed files with 128 additions and 82 deletions
				
			
		|  | @ -76,29 +76,31 @@ def needs_declaration(fullpath): | |||
|     -c: recognize Python source files trying to compile them | ||||
|     -d: debug output""" % sys.argv[0] | ||||
| 
 | ||||
| try: | ||||
|     opts, args = getopt.getopt(sys.argv[1:], 'cd') | ||||
| except getopt.error as msg: | ||||
|     print(msg, file=sys.stderr) | ||||
|     print(usage, file=sys.stderr) | ||||
|     sys.exit(1) | ||||
| if __name__ == '__main__': | ||||
| 
 | ||||
| is_python = pysource.looks_like_python | ||||
| debug = False | ||||
|     try: | ||||
|         opts, args = getopt.getopt(sys.argv[1:], 'cd') | ||||
|     except getopt.error as msg: | ||||
|         print(msg, file=sys.stderr) | ||||
|         print(usage, file=sys.stderr) | ||||
|         sys.exit(1) | ||||
| 
 | ||||
| for o, a in opts: | ||||
|     if o == '-c': | ||||
|         is_python = pysource.can_be_compiled | ||||
|     elif o == '-d': | ||||
|         debug = True | ||||
|     is_python = pysource.looks_like_python | ||||
|     debug = False | ||||
| 
 | ||||
| if not args: | ||||
|     print(usage, file=sys.stderr) | ||||
|     sys.exit(1) | ||||
|     for o, a in opts: | ||||
|         if o == '-c': | ||||
|             is_python = pysource.can_be_compiled | ||||
|         elif o == '-d': | ||||
|             debug = True | ||||
| 
 | ||||
| for fullpath in pysource.walk_python_files(args, is_python): | ||||
|     if debug: | ||||
|         print("Testing for coding: %s" % fullpath) | ||||
|     result = needs_declaration(fullpath) | ||||
|     if result: | ||||
|         print(fullpath) | ||||
|     if not args: | ||||
|         print(usage, file=sys.stderr) | ||||
|         sys.exit(1) | ||||
| 
 | ||||
|     for fullpath in pysource.walk_python_files(args, is_python): | ||||
|         if debug: | ||||
|             print("Testing for coding: %s" % fullpath) | ||||
|         result = needs_declaration(fullpath) | ||||
|         if result: | ||||
|             print(fullpath) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 R David Murray
						R David Murray