@@ -1100,31 +1100,32 @@ static PyObject *
1100
1100
fileio_repr (fileio * self )
1101
1101
{
1102
1102
PyObject * nameobj , * res ;
1103
+ const char * type_name = Py_TYPE ((PyObject * ) self )-> tp_name ;
1103
1104
1104
- if (self -> fd < 0 )
1105
- return PyUnicode_FromFormat ("<_io.FileIO [closed]>" );
1105
+ if (self -> fd < 0 ) {
1106
+ return PyUnicode_FromFormat ("<%.100s [closed]>" , type_name );
1107
+ }
1106
1108
1107
1109
if (PyObject_GetOptionalAttr ((PyObject * ) self , & _Py_ID (name ), & nameobj ) < 0 ) {
1108
1110
return NULL ;
1109
1111
}
1110
1112
if (nameobj == NULL ) {
1111
1113
res = PyUnicode_FromFormat (
1112
- "<_io.FileIO fd=%d mode='%s' closefd=%s>" ,
1113
- self -> fd , mode_string (self ), self -> closefd ? "True" : "False" );
1114
+ "<%.100s fd=%d mode='%s' closefd=%s>" ,
1115
+ type_name , self -> fd , mode_string (self ), self -> closefd ? "True" : "False" );
1114
1116
}
1115
1117
else {
1116
1118
int status = Py_ReprEnter ((PyObject * )self );
1117
1119
res = NULL ;
1118
1120
if (status == 0 ) {
1119
1121
res = PyUnicode_FromFormat (
1120
- "<_io.FileIO name=%R mode='%s' closefd=%s>" ,
1121
- nameobj , mode_string (self ), self -> closefd ? "True" : "False" );
1122
+ "<%.100s name=%R mode='%s' closefd=%s>" ,
1123
+ type_name , nameobj , mode_string (self ), self -> closefd ? "True" : "False" );
1122
1124
Py_ReprLeave ((PyObject * )self );
1123
1125
}
1124
1126
else if (status > 0 ) {
1125
1127
PyErr_Format (PyExc_RuntimeError ,
1126
- "reentrant call inside %s.__repr__" ,
1127
- Py_TYPE (self )-> tp_name );
1128
+ "reentrant call inside %.100s.__repr__" , type_name );
1128
1129
}
1129
1130
Py_DECREF (nameobj );
1130
1131
}
0 commit comments