Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 42071:825041fc8e2c
Rip out the file object's implementation.
Fixed test_import.py while I was at it.
However, there's still a problem in import.c -- get_file() can leak a
FILE struct (not a file descriptor though). I'm not sure how to fix
this; closing the FILE* closes the file descriptor, and that's the
wrong thing to do when there's still a Python file object keeping the
file descriptor open. I also would rather not mess with dup(), as it
won't port to Windows.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 12 Jun 2007 23:30:11 +0000 |
| parents | cd125fe83051 |
| children | 29ba6c399090 |
line wrap: on
line diff
--- a/Python/pythonrun.c Tue Jun 12 18:07:38 2007 +0000 +++ b/Python/pythonrun.c Tue Jun 12 23:30:11 2007 +0000 @@ -155,7 +155,6 @@ #if defined(HAVE_LANGINFO_H) && defined(CODESET) char *codeset; char *saved_locale; - PyObject *sys_stream, *sys_isatty; #endif extern void _Py_ReadyTypes(void); @@ -273,39 +272,6 @@ free(saved_locale); if (codeset) { - sys_stream = PySys_GetObject("stdin"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty) && - PyFile_Check(sys_stream)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stdin"); - } - Py_XDECREF(sys_isatty); - - sys_stream = PySys_GetObject("stdout"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty) && - PyFile_Check(sys_stream)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stdout"); - } - Py_XDECREF(sys_isatty); - - sys_stream = PySys_GetObject("stderr"); - sys_isatty = PyObject_CallMethod(sys_stream, "isatty", ""); - if (!sys_isatty) - PyErr_Clear(); - if(sys_isatty && PyObject_IsTrue(sys_isatty) && - PyFile_Check(sys_stream)) { - if (!PyFile_SetEncoding(sys_stream, codeset)) - Py_FatalError("Cannot set codeset of stderr"); - } - Py_XDECREF(sys_isatty); - if (!Py_FileSystemDefaultEncoding) Py_FileSystemDefaultEncoding = codeset; else
