mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	bpo-44667: Treat correctly lines ending with comments and no newlines in the Python tokenizer (GH-27499) (GH-27501)
(cherry picked from commit b6bde9fc42)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									2efa78180d
								
							
						
					
					
						commit
						2d11797c81
					
				
					 3 changed files with 15 additions and 1 deletions
				
			
		|  | @ -602,7 +602,7 @@ def _tokenize(readline, encoding): | |||
|                 pos += 1 | ||||
| 
 | ||||
|     # Add an implicit NEWLINE if the input doesn't end in one | ||||
|     if last_line and last_line[-1] not in '\r\n': | ||||
|     if last_line and last_line[-1] not in '\r\n' and not last_line.strip().startswith("#"): | ||||
|         yield TokenInfo(NEWLINE, '', (lnum - 1, len(last_line)), (lnum - 1, len(last_line) + 1), '') | ||||
|     for indent in indents[1:]:                 # pop remaining indent levels | ||||
|         yield TokenInfo(DEDENT, '', (lnum, 0), (lnum, 0), '') | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)