mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	[3.13] gh-121804: Always show error location for SyntaxError's in new repl (GH-121886) (#123148)
(cherry picked from commit 354d55eb1f)
			
			
This commit is contained in:
		
							parent
							
								
									21399a0963
								
							
						
					
					
						commit
						c8f4069ab1
					
				
					 5 changed files with 29 additions and 7 deletions
				
			
		|  | @ -161,8 +161,8 @@ def __init__( | |||
|         super().__init__(locals=locals, filename=filename, local_exit=local_exit)  # type: ignore[call-arg] | ||||
|         self.can_colorize = _colorize.can_colorize() | ||||
| 
 | ||||
|     def showsyntaxerror(self, filename=None): | ||||
|         super().showsyntaxerror(colorize=self.can_colorize) | ||||
|     def showsyntaxerror(self, filename=None, **kwargs): | ||||
|         super().showsyntaxerror(colorize=self.can_colorize, **kwargs) | ||||
| 
 | ||||
|     def showtraceback(self): | ||||
|         super().showtraceback(colorize=self.can_colorize) | ||||
|  | @ -171,7 +171,7 @@ def runsource(self, source, filename="<input>", symbol="single"): | |||
|         try: | ||||
|             tree = ast.parse(source) | ||||
|         except (SyntaxError, OverflowError, ValueError): | ||||
|             self.showsyntaxerror(filename) | ||||
|             self.showsyntaxerror(filename, source=source) | ||||
|             return False | ||||
|         if tree.body: | ||||
|             *_, last_stmt = tree.body | ||||
|  | @ -188,10 +188,10 @@ def runsource(self, source, filename="<input>", symbol="single"): | |||
|                         f"Try the asyncio REPL ({python} -m asyncio) to use" | ||||
|                         f" top-level 'await' and run background asyncio tasks." | ||||
|                     ) | ||||
|                 self.showsyntaxerror(filename) | ||||
|                 self.showsyntaxerror(filename, source=source) | ||||
|                 return False | ||||
|             except (OverflowError, ValueError): | ||||
|                 self.showsyntaxerror(filename) | ||||
|                 self.showsyntaxerror(filename, source=source) | ||||
|                 return False | ||||
| 
 | ||||
|             if code is None: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sergey B Kirpichev
						Sergey B Kirpichev