@@ -1078,31 +1078,32 @@ static PyObject *
1078
1078
fileio_repr (fileio * self )
1079
1079
{
1080
1080
PyObject * nameobj , * res ;
1081
+ const char * type_name = Py_TYPE ((PyObject * ) self )-> tp_name ;
1081
1082
1082
- if (self -> fd < 0 )
1083
- return PyUnicode_FromFormat ("<_io.FileIO [closed]>" );
1083
+ if (self -> fd < 0 ) {
1084
+ return PyUnicode_FromFormat ("<%s [closed]>" , type_name );
1085
+ }
1084
1086
1085
1087
if (_PyObject_LookupAttr ((PyObject * ) self , & _Py_ID (name ), & nameobj ) < 0 ) {
1086
1088
return NULL ;
1087
1089
}
1088
1090
if (nameobj == NULL ) {
1089
1091
res = PyUnicode_FromFormat (
1090
- "<_io.FileIO fd=%d mode='%s' closefd=%s>" ,
1091
- self -> fd , mode_string (self ), self -> closefd ? "True" : "False" );
1092
+ "<%s fd=%d mode='%s' closefd=%s>" ,
1093
+ type_name , self -> fd , mode_string (self ), self -> closefd ? "True" : "False" );
1092
1094
}
1093
1095
else {
1094
1096
int status = Py_ReprEnter ((PyObject * )self );
1095
1097
res = NULL ;
1096
1098
if (status == 0 ) {
1097
1099
res = PyUnicode_FromFormat (
1098
- "<_io.FileIO name=%R mode='%s' closefd=%s>" ,
1099
- nameobj , mode_string (self ), self -> closefd ? "True" : "False" );
1100
+ "<%s name=%R mode='%s' closefd=%s>" ,
1101
+ type_name , nameobj , mode_string (self ), self -> closefd ? "True" : "False" );
1100
1102
Py_ReprLeave ((PyObject * )self );
1101
1103
}
1102
1104
else if (status > 0 ) {
1103
1105
PyErr_Format (PyExc_RuntimeError ,
1104
- "reentrant call inside %s.__repr__" ,
1105
- Py_TYPE (self )-> tp_name );
1106
+ "reentrant call inside %s.__repr__" , type_name );
1106
1107
}
1107
1108
Py_DECREF (nameobj );
1108
1109
}
0 commit comments