mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	don't segfault when \N escapes are used and unicodedata fails to load
Fixes #4367
This commit is contained in:
		
							parent
							
								
									d42941751c
								
							
						
					
					
						commit
						c078f929cb
					
				
					 3 changed files with 30 additions and 3 deletions
				
			
		|  | @ -1294,13 +1294,14 @@ ast_for_atom(struct compiling *c, const node *n) | |||
|             if (PyErr_ExceptionMatches(PyExc_UnicodeError)){ | ||||
|                 PyObject *type, *value, *tback, *errstr; | ||||
|                 PyErr_Fetch(&type, &value, &tback); | ||||
|                 errstr = ((PyUnicodeErrorObject *)value)->reason; | ||||
|                 errstr = PyObject_Str(value); | ||||
|                 if (errstr) { | ||||
|                     char *s = ""; | ||||
|                     char buf[128]; | ||||
|                     s = PyString_AsString(errstr); | ||||
|                     PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s); | ||||
|                     ast_error(n, buf); | ||||
|                     Py_DECREF(errstr); | ||||
|                 } else { | ||||
|                     ast_error(n, "(unicode error) unknown error"); | ||||
|                 } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Benjamin Peterson
						Benjamin Peterson