Issue #19512: fileio_init() reuses PyId_name identifier instead of "name"
literal string
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 27995e5..0e1e709 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -59,6 +59,8 @@
PyTypeObject PyFileIO_Type;
+_Py_IDENTIFIER(name);
+
#define PyFileIO_Check(op) (PyObject_TypeCheck((op), &PyFileIO_Type))
int
@@ -427,7 +429,7 @@
_setmode(self->fd, O_BINARY);
#endif
- if (PyObject_SetAttrString((PyObject *)self, "name", nameobj) < 0)
+ if (_PyObject_SetAttrId((PyObject *)self, &PyId_name, nameobj) < 0)
goto error;
if (self->appending) {
@@ -1036,7 +1038,6 @@
static PyObject *
fileio_repr(fileio *self)
{
- _Py_IDENTIFIER(name);
PyObject *nameobj, *res;
if (self->fd < 0)