From 5397039504fa45f7a41b8afe5f0cb485ad4dbcf1 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 12 Jun 2007 00:28:30 +0000 Subject: Minimal changes to make the "freeze" tool work again. There are other issues left, but these were basics (e.g. keys().sort()). --- Objects/fileobject.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'Objects') diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 469eacd2f2..2d9fcf9b17 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -265,24 +265,19 @@ cleanup: PyObject * PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *)) { - PyErr_SetString(PyExc_SystemError, - "attempt to create old file from FILE *"); - return NULL; -#if 0 - PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type, - NULL, NULL); - if (f != NULL) { - PyObject *o_name = PyString_FromString(name); - if (o_name == NULL) - return NULL; - if (fill_file_fields(f, fp, o_name, mode, close) == NULL) { - Py_DECREF(f); - f = NULL; - } - Py_DECREF(o_name); + PyObject *io = NULL, *stream = NULL; + + io = PyImport_ImportModule("io"); + if (io == NULL) + return NULL; + stream = PyObject_CallMethod(io, "open", "ss", name, mode); + if (stream == NULL) { + Py_XDECREF(io); + return NULL; } - return (PyObject *) f; -#endif + if (close != NULL) + close(fp); + return stream; } PyObject * -- cgit v1.2.1