Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 61846:815ba3872f85
Issue #3798: sys.exit(message) writes the message to sys.stderr file, instead
of the C file stderr, to use stderr encoding and error handler
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Fri, 21 May 2010 23:45:42 +0000 |
| parents | deed5fce82d6 |
| children | a25ad9c4ace0 |
comparison
equal
deleted
inserted
replaced
| 61844:2ea90920cc10 | 61846:815ba3872f85 |
|---|---|
| 1384 } | 1384 } |
| 1385 if (PyLong_Check(value)) | 1385 if (PyLong_Check(value)) |
| 1386 exitcode = (int)PyLong_AsLong(value); | 1386 exitcode = (int)PyLong_AsLong(value); |
| 1387 else { | 1387 else { |
| 1388 PyObject *sys_stderr = PySys_GetObject("stderr"); | 1388 PyObject *sys_stderr = PySys_GetObject("stderr"); |
| 1389 if (sys_stderr != NULL) | 1389 if (sys_stderr != NULL && sys_stderr != Py_None) { |
| 1390 PyObject_CallMethod(sys_stderr, "flush", NULL); | 1390 PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW); |
| 1391 PyObject_Print(value, stderr, Py_PRINT_RAW); | 1391 } else { |
| 1392 fflush(stderr); | 1392 PyObject_Print(value, stderr, Py_PRINT_RAW); |
| 1393 fflush(stderr); | |
| 1394 } | |
| 1393 PySys_WriteStderr("\n"); | 1395 PySys_WriteStderr("\n"); |
| 1394 exitcode = 1; | 1396 exitcode = 1; |
| 1395 } | 1397 } |
| 1396 done: | 1398 done: |
| 1397 /* Restore and clear the exception info, in order to properly decref | 1399 /* Restore and clear the exception info, in order to properly decref |
