Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 62189:d281ed59ff0b
sys_pyfile_write() does nothing if file is NULL
mywrite() falls back to the C file object if sys_pyfile_write() returns an
error. This patch fixes a segfault is Py_FatalError() is called in an early
stage of Python initialization.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Tue, 08 Jun 2010 20:46:00 +0000 |
| parents | 600c23127207 |
| children | 1f37d082a9aa |
comparison
equal
deleted
inserted
replaced
| 62188:a06ad7383552 | 62189:d281ed59ff0b |
|---|---|
| 1837 sys_pyfile_write(const char *text, PyObject *file) | 1837 sys_pyfile_write(const char *text, PyObject *file) |
| 1838 { | 1838 { |
| 1839 PyObject *unicode = NULL, *writer = NULL, *args = NULL, *result = NULL; | 1839 PyObject *unicode = NULL, *writer = NULL, *args = NULL, *result = NULL; |
| 1840 int err; | 1840 int err; |
| 1841 | 1841 |
| 1842 if (file == NULL) | |
| 1843 return -1; | |
| 1844 | |
| 1842 unicode = PyUnicode_FromString(text); | 1845 unicode = PyUnicode_FromString(text); |
| 1843 if (unicode == NULL) | 1846 if (unicode == NULL) |
| 1844 goto error; | 1847 goto error; |
| 1845 | 1848 |
| 1846 writer = PyObject_GetAttrString(file, "write"); | 1849 writer = PyObject_GetAttrString(file, "write"); |
