mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	When errno is zero, avoid calling strerror() and use "Error" for the
message.
This commit is contained in:
		
							parent
							
								
									b0e5718643
								
							
						
					
					
						commit
						e0e59829e0
					
				
					 1 changed files with 8 additions and 3 deletions
				
			
		|  | @ -282,15 +282,20 @@ PyErr_SetFromErrnoWithFilename(exc, filename) | ||||||
| 	char *filename; | 	char *filename; | ||||||
| { | { | ||||||
| 	PyObject *v; | 	PyObject *v; | ||||||
|  | 	char *s; | ||||||
| 	int i = errno; | 	int i = errno; | ||||||
| #ifdef EINTR | #ifdef EINTR | ||||||
| 	if (i == EINTR && PyErr_CheckSignals()) | 	if (i == EINTR && PyErr_CheckSignals()) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| #endif | #endif | ||||||
| 	if (filename != NULL && Py_UseClassExceptionsFlag) | 	if (i == 0) | ||||||
| 		v = Py_BuildValue("(iss)", i, strerror(i), filename); | 		s = "Error"; /* Sometimes errno didn't get set */ | ||||||
| 	else | 	else | ||||||
| 		v = Py_BuildValue("(is)", i, strerror(i)); | 		s = strerror(i); | ||||||
|  | 	if (filename != NULL && Py_UseClassExceptionsFlag) | ||||||
|  | 		v = Py_BuildValue("(iss)", i, s, filename); | ||||||
|  | 	else | ||||||
|  | 		v = Py_BuildValue("(is)", i, s); | ||||||
| 	if (v != NULL) { | 	if (v != NULL) { | ||||||
| 		PyErr_SetObject(exc, v); | 		PyErr_SetObject(exc, v); | ||||||
| 		Py_DECREF(v); | 		Py_DECREF(v); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum