Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 59865:c2d2e26bcf7f 3.1
Merged revisions 78872 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r78872 | victor.stinner | 2010-03-12 15:45:56 +0100 (ven., 12 mars 2010) | 12 lines
Merged revisions 78826 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.
........
................
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Sun, 21 Mar 2010 21:48:45 +0000 |
| parents | 4bed796ee0d7 |
| children | a366d631a629 |
comparison
equal
deleted
inserted
replaced
| 59864:4293c33668df | 59865:c2d2e26bcf7f |
|---|---|
| 294 | 294 |
| 295 initmain(); /* Module __main__ */ | 295 initmain(); /* Module __main__ */ |
| 296 if (initstdio() < 0) | 296 if (initstdio() < 0) |
| 297 Py_FatalError( | 297 Py_FatalError( |
| 298 "Py_Initialize: can't initialize sys standard streams"); | 298 "Py_Initialize: can't initialize sys standard streams"); |
| 299 if (!Py_NoSiteFlag) | |
| 300 initsite(); /* Module site */ | |
| 301 | 299 |
| 302 /* auto-thread-state API, if available */ | 300 /* auto-thread-state API, if available */ |
| 303 #ifdef WITH_THREAD | 301 #ifdef WITH_THREAD |
| 304 _PyGILState_Init(interp, tstate); | 302 _PyGILState_Init(interp, tstate); |
| 305 #endif /* WITH_THREAD */ | 303 #endif /* WITH_THREAD */ |
| 304 | |
| 305 if (!Py_NoSiteFlag) | |
| 306 initsite(); /* Module site */ | |
| 306 } | 307 } |
| 307 | 308 |
| 308 void | 309 void |
| 309 Py_Initialize(void) | 310 Py_Initialize(void) |
| 310 { | 311 { |
| 709 /* Import the site module (not into __main__ though) */ | 710 /* Import the site module (not into __main__ though) */ |
| 710 | 711 |
| 711 static void | 712 static void |
| 712 initsite(void) | 713 initsite(void) |
| 713 { | 714 { |
| 714 PyObject *m, *f; | 715 PyObject *m; |
| 715 m = PyImport_ImportModule("site"); | 716 m = PyImport_ImportModule("site"); |
| 716 if (m == NULL) { | 717 if (m == NULL) { |
| 717 f = PySys_GetObject("stderr"); | 718 PyErr_Print(); |
| 718 if (f == NULL || f == Py_None) | 719 Py_Finalize(); |
| 719 return; | 720 exit(1); |
| 720 if (Py_VerboseFlag) { | |
| 721 PyFile_WriteString( | |
| 722 "'import site' failed; traceback:\n", f); | |
| 723 PyErr_Print(); | |
| 724 } | |
| 725 else { | |
| 726 PyFile_WriteString( | |
| 727 "'import site' failed; use -v for traceback\n", f); | |
| 728 PyErr_Clear(); | |
| 729 } | |
| 730 } | 721 } |
| 731 else { | 722 else { |
| 732 Py_DECREF(m); | 723 Py_DECREF(m); |
| 733 } | 724 } |
| 734 } | 725 } |
| 1905 PyObject *v, *w, *errtype, *errtext; | 1896 PyObject *v, *w, *errtype, *errtext; |
| 1906 PyObject* u = NULL; | 1897 PyObject* u = NULL; |
| 1907 char *msg = NULL; | 1898 char *msg = NULL; |
| 1908 errtype = PyExc_SyntaxError; | 1899 errtype = PyExc_SyntaxError; |
| 1909 switch (err->error) { | 1900 switch (err->error) { |
| 1901 case E_ERROR: | |
| 1902 return; | |
| 1910 case E_SYNTAX: | 1903 case E_SYNTAX: |
| 1911 errtype = PyExc_IndentationError; | 1904 errtype = PyExc_IndentationError; |
| 1912 if (err->expected == INDENT) | 1905 if (err->expected == INDENT) |
| 1913 msg = "expected an indented block"; | 1906 msg = "expected an indented block"; |
| 1914 else if (err->token == INDENT) | 1907 else if (err->token == INDENT) |
