diff options
author | Guido van Rossum <guido@python.org> | 2007-06-12 00:28:30 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-06-12 00:28:30 +0000 |
commit | 5397039504fa45f7a41b8afe5f0cb485ad4dbcf1 (patch) | |
tree | e5b8d338ccca2ffe33bd31d793d31536997d463d /Objects | |
parent | 0aa35f8709fa5c182254487c609ac4a3ba929ba6 (diff) | |
download | cpython-git-5397039504fa45f7a41b8afe5f0cb485ad4dbcf1.tar.gz |
Minimal changes to make the "freeze" tool work again.
There are other issues left, but these were basics (e.g. keys().sort()).
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/fileobject.c | 29 |
1 files changed, 12 insertions, 17 deletions
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 * |