[Python-checkins] python/dist/src/Objects fileobject.c,2.188,2.189
mondragon at users.sourceforge.net
mondragon at users.sourceforge.net
Sun Mar 21 15:24:09 EST 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15479/Objects
Modified Files:
fileobject.c
Log Message:
Changed file.name to be the object passed as the 'name' argument to file()
Fixes SF Bug #773356
Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.188
retrieving revision 2.189
diff -C2 -d -r2.188 -r2.189
*** fileobject.c 19 Mar 2004 15:22:36 -0000 2.188
--- fileobject.c 21 Mar 2004 20:24:07 -0000 2.189
***************
*** 96,101 ****
static PyObject *
! fill_file_fields(PyFileObject *f, FILE *fp, char *name, char *mode,
! int (*close)(FILE *), PyObject *wname)
{
assert(f != NULL);
--- 96,101 ----
static PyObject *
! fill_file_fields(PyFileObject *f, FILE *fp, PyObject *name, char *mode,
! int (*close)(FILE *))
{
assert(f != NULL);
***************
*** 106,115 ****
Py_DECREF(f->f_mode);
Py_DECREF(f->f_encoding);
! #ifdef Py_USING_UNICODE
! if (wname)
! f->f_name = PyUnicode_FromObject(wname);
! else
! #endif
! f->f_name = PyString_FromString(name);
f->f_mode = PyString_FromString(mode);
--- 106,113 ----
Py_DECREF(f->f_mode);
Py_DECREF(f->f_encoding);
!
! Py_INCREF (name);
! f->f_name = name;
!
f->f_mode = PyString_FromString(mode);
***************
*** 203,211 ****
mode);
else
- #ifdef MS_WINDOWS
PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name);
- #else
- PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
- #endif /* MS_WINDOWS */
f = NULL;
}
--- 201,205 ----
***************
*** 221,228 ****
NULL, NULL);
if (f != NULL) {
! if (fill_file_fields(f, fp, name, mode, close, NULL) == NULL) {
Py_DECREF(f);
f = NULL;
}
}
return (PyObject *) f;
--- 215,224 ----
NULL, NULL);
if (f != NULL) {
! PyObject *o_name = PyString_FromString(name);
! if (fill_file_fields(f, fp, o_name, mode, close) == NULL) {
Py_DECREF(f);
f = NULL;
}
+ Py_DECREF(o_name);
}
return (PyObject *) f;
***************
*** 1854,1859 ****
kwlist, &po, &mode, &bufsize)) {
wideargument = 1;
! if (fill_file_fields(foself, NULL, name, mode,
! fclose, po) == NULL)
goto Error;
} else {
--- 1850,1855 ----
kwlist, &po, &mode, &bufsize)) {
wideargument = 1;
! if (fill_file_fields(foself, NULL, po, mode,
! fclose) == NULL)
goto Error;
} else {
***************
*** 1866,1869 ****
--- 1862,1867 ----
if (!wideargument) {
+ PyObject *o_name;
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|si:file", kwlist,
Py_FileSystemDefaultEncoding,
***************
*** 1871,1876 ****
&mode, &bufsize))
return -1;
! if (fill_file_fields(foself, NULL, name, mode,
! fclose, NULL) == NULL)
goto Error;
}
--- 1869,1880 ----
&mode, &bufsize))
return -1;
!
! /* We parse again to get the name as a PyObject */
! if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", kwlist,
! &o_name, &mode, &bufsize))
! return -1;
!
! if (fill_file_fields(foself, NULL, o_name, mode,
! fclose) == NULL)
goto Error;
}
More information about the Python-checkins
mailing list