mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	[3.9] bpo-44409: Fix error location in tokenizer errors that happen during initialization (GH-26712). (GH-26723)
(cherry picked from commit 507ed6fa1d)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
			
			
This commit is contained in:
		
							parent
							
								
									7f021952b2
								
							
						
					
					
						commit
						0d0a9eaa82
					
				
					 3 changed files with 4 additions and 0 deletions
				
			
		|  | @ -235,6 +235,7 @@ def baz(): | ||||||
|             """, 9, 20) |             """, 9, 20) | ||||||
|         check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4) |         check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4) | ||||||
|         check("(1+)", 1, 4) |         check("(1+)", 1, 4) | ||||||
|  |         check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0, -1) | ||||||
| 
 | 
 | ||||||
|         # Errors thrown by symtable.c |         # Errors thrown by symtable.c | ||||||
|         check('x = [(yield i) for i in range(3)]', 1, 5) |         check('x = [(yield i) for i in range(3)]', 1, 5) | ||||||
|  |  | ||||||
|  | @ -0,0 +1,2 @@ | ||||||
|  | Fix error location information for tokenizer errors raised on initialization | ||||||
|  | of the tokenizer. Patch by Pablo Galindo. | ||||||
|  | @ -269,6 +269,7 @@ static void | ||||||
| raise_tokenizer_init_error(PyObject *filename) | raise_tokenizer_init_error(PyObject *filename) | ||||||
| { | { | ||||||
|     if (!(PyErr_ExceptionMatches(PyExc_LookupError) |     if (!(PyErr_ExceptionMatches(PyExc_LookupError) | ||||||
|  |           || PyErr_ExceptionMatches(PyExc_SyntaxError) | ||||||
|           || PyErr_ExceptionMatches(PyExc_ValueError) |           || PyErr_ExceptionMatches(PyExc_ValueError) | ||||||
|           || PyErr_ExceptionMatches(PyExc_UnicodeDecodeError))) { |           || PyErr_ExceptionMatches(PyExc_UnicodeDecodeError))) { | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Pablo Galindo
						Pablo Galindo