Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 61654:f3f95ed82744
handle_system_exit() flushs files to warranty the output order
PyObject_Print() writes into the C object stderr, whereas PySys_WriteStderr()
writes into the Python object sys.stderr. Each object has its own buffer, so
call sys.stderr.flush() and fflush(stderr).
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Mon, 17 May 2010 08:58:51 +0000 |
| parents | 47b4da86b9b9 |
| children | 942b3c168f15 |
comparison
equal
deleted
inserted
replaced
| 61653:556961f4f16d | 61654:f3f95ed82744 |
|---|---|
| 1365 just let the else clause below print the error. */ | 1365 just let the else clause below print the error. */ |
| 1366 } | 1366 } |
| 1367 if (PyLong_Check(value)) | 1367 if (PyLong_Check(value)) |
| 1368 exitcode = (int)PyLong_AsLong(value); | 1368 exitcode = (int)PyLong_AsLong(value); |
| 1369 else { | 1369 else { |
| 1370 PyObject *sys_stderr = PySys_GetObject("stderr"); | |
| 1371 if (sys_stderr != NULL) | |
| 1372 PyObject_CallMethod(sys_stderr, "flush", NULL); | |
| 1370 PyObject_Print(value, stderr, Py_PRINT_RAW); | 1373 PyObject_Print(value, stderr, Py_PRINT_RAW); |
| 1374 fflush(stderr); | |
| 1371 PySys_WriteStderr("\n"); | 1375 PySys_WriteStderr("\n"); |
| 1372 exitcode = 1; | 1376 exitcode = 1; |
| 1373 } | 1377 } |
| 1374 done: | 1378 done: |
| 1375 /* Restore and clear the exception info, in order to properly decref | 1379 /* Restore and clear the exception info, in order to properly decref |
