comparison Python/pythonrun.c @ 59822:8d8c9bf2a04e 2.6

Partial backport of r78826: leave import site error handler unchanged (print the error and continue). Merged revisions 78826-78827 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78826 | victor.stinner | 2010-03-10 23:30:19 +0100 (mer., 10 mars 2010) | 5 lines 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. ........ r78827 | victor.stinner | 2010-03-10 23:45:04 +0100 (mer., 10 mars 2010) | 4 lines ooops, fix error message in execusercustomize() Copy/paste failure :-) ........
author Victor Stinner <victor.stinner@haypocalc.com>
date Sun, 21 Mar 2010 14:02:32 +0000
parents 2abc3b4bce7c
children fb719049044f
comparison
equal deleted inserted replaced
59821:581263af5820 59822:8d8c9bf2a04e
243 PyErr_Clear(); 243 PyErr_Clear();
244 Py_XDECREF(warnings_module); 244 Py_XDECREF(warnings_module);
245 } 245 }
246 246
247 initmain(); /* Module __main__ */ 247 initmain(); /* Module __main__ */
248 if (!Py_NoSiteFlag)
249 initsite(); /* Module site */
250 248
251 /* auto-thread-state API, if available */ 249 /* auto-thread-state API, if available */
252 #ifdef WITH_THREAD 250 #ifdef WITH_THREAD
253 _PyGILState_Init(interp, tstate); 251 _PyGILState_Init(interp, tstate);
254 #endif /* WITH_THREAD */ 252 #endif /* WITH_THREAD */
253
254 if (!Py_NoSiteFlag)
255 initsite(); /* Module site */
255 256
256 if ((p = Py_GETENV("PYTHONIOENCODING")) && *p != '\0') { 257 if ((p = Py_GETENV("PYTHONIOENCODING")) && *p != '\0') {
257 p = icodeset = codeset = strdup(p); 258 p = icodeset = codeset = strdup(p);
258 free_codeset = 1; 259 free_codeset = 1;
259 errors = strchr(p, ':'); 260 errors = strchr(p, ':');
279 PyObject *enc = PyCodec_Encoder(loc_codeset); 280 PyObject *enc = PyCodec_Encoder(loc_codeset);
280 if (enc) { 281 if (enc) {
281 loc_codeset = strdup(loc_codeset); 282 loc_codeset = strdup(loc_codeset);
282 Py_DECREF(enc); 283 Py_DECREF(enc);
283 } else { 284 } else {
284 loc_codeset = NULL; 285 if (PyErr_ExceptionMatches(PyExc_LookupError)) {
285 PyErr_Clear(); 286 PyErr_Clear();
287 loc_codeset = NULL;
288 } else {
289 PyErr_Print();
290 exit(1);
291 }
286 } 292 }
287 } else 293 } else
288 loc_codeset = NULL; 294 loc_codeset = NULL;
289 setlocale(LC_CTYPE, saved_locale); 295 setlocale(LC_CTYPE, saved_locale);
290 free(saved_locale); 296 free(saved_locale);
1541 PyObject *v, *w, *errtype; 1547 PyObject *v, *w, *errtype;
1542 PyObject* u = NULL; 1548 PyObject* u = NULL;
1543 char *msg = NULL; 1549 char *msg = NULL;
1544 errtype = PyExc_SyntaxError; 1550 errtype = PyExc_SyntaxError;
1545 switch (err->error) { 1551 switch (err->error) {
1552 case E_ERROR:
1553 return;
1546 case E_SYNTAX: 1554 case E_SYNTAX:
1547 errtype = PyExc_IndentationError; 1555 errtype = PyExc_IndentationError;
1548 if (err->expected == INDENT) 1556 if (err->expected == INDENT)
1549 msg = "expected an indented block"; 1557 msg = "expected an indented block";
1550 else if (err->token == INDENT) 1558 else if (err->token == INDENT)