Issue #3137: Don't ignore errors at startup, especially a keyboard interrupt
(SIGINT). If an error occurs while importing the site module, the error is
printed and Python exits. Initialize the GIL before importing the site
module.
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index b881e7c..d60b256 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -817,8 +817,12 @@
return -1;
error_clear:
- /* Fallback to iso-8859-1: for backward compatibility */
Py_DECREF(enc);
+ if (!PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) {
+ tok->done = E_ERROR;
+ return -1;
+ }
+ /* Fallback to iso-8859-1: for backward compatibility */
PyErr_Clear();
return 0;
}