diff Python/import.c @ 49020:3fa066d2a397

#3773: Check for errors around the use of PyTokenizer_FindEncoding(). reviewed by Brett Cannon.
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Thu, 04 Sep 2008 22:34:09 +0000
parents 812ea105b1b0
children f7123d45d0c4
line wrap: on
line diff
--- a/Python/import.c	Thu Sep 04 21:32:09 2008 +0000
+++ b/Python/import.c	Thu Sep 04 22:34:09 2008 +0000
@@ -2830,6 +2830,8 @@
 			   memory. */
 			found_encoding = PyTokenizer_FindEncoding(fd);
 			lseek(fd, 0, 0); /* Reset position */
+			if (found_encoding == NULL && PyErr_Occurred())
+				return NULL;
 			encoding = (found_encoding != NULL) ? found_encoding :
 				   (char*)PyUnicode_GetDefaultEncoding();
 		}