Issue #9425: PyFile_FromFd() ignores the name argument
This function is only by imp.find_module() which does return the filename in a
separated variable.
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 3709e00..9288e35 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -29,7 +29,7 @@
PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding,
char *errors, char *newline, int closefd)
{
- PyObject *io, *stream, *nameobj = NULL;
+ PyObject *io, *stream;
io = PyImport_ImportModule("io");
if (io == NULL)
@@ -40,16 +40,8 @@
Py_DECREF(io);
if (stream == NULL)
return NULL;
- if (name != NULL) {
- nameobj = PyUnicode_DecodeFSDefault(name);
- if (nameobj == NULL)
- PyErr_Clear();
- else {
- if (PyObject_SetAttrString(stream, "name", nameobj) < 0)
- PyErr_Clear();
- Py_DECREF(nameobj);
- }
- }
+ /* ignore name attribute because the name attribute of _BufferedIOMixin
+ and TextIOWrapper is read only */
return stream;
}