summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-06-12 00:28:30 (GMT)
committerGuido van Rossum <guido@python.org>2007-06-12 00:28:30 (GMT)
commit5397039504fa45f7a41b8afe5f0cb485ad4dbcf1 (patch)
treee5b8d338ccca2ffe33bd31d793d31536997d463d /Objects/fileobject.c
parent0aa35f8709fa5c182254487c609ac4a3ba929ba6 (diff)
downloadcpython-5397039504fa45f7a41b8afe5f0cb485ad4dbcf1.zip
cpython-5397039504fa45f7a41b8afe5f0cb485ad4dbcf1.tar.gz
cpython-5397039504fa45f7a41b8afe5f0cb485ad4dbcf1.tar.bz2
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/fileobject.c')
-rw-r--r--Objects/fileobject.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 469eacd..2d9fcf9 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 *