@@ -1289,91 +1289,8 @@ typealias_get_value(typealiasobject *ta)
12891289static PyObject *
12901290typealias_repr (PyObject * self )
12911291{
1292- Py_ssize_t res = Py_ReprEnter (self );
1293- if (res > 0 ) {
1294- return PyUnicode_FromString ("..." );
1295- }
1296- else if (res < 0 ) {
1297- return NULL ;
1298- }
1299-
13001292 typealiasobject * ta = (typealiasobject * )self ;
1301- PyObject * value_repr = NULL ;
1302- PyObject * value = typealias_get_value (ta );
1303- if (value == NULL ) {
1304- PyErr_Clear ();
1305- value_repr = PyUnicode_FromString ("<evaluation failed>" );
1306- }
1307- // Show "int" instead of "<class 'int'>"
1308- else if (PyType_Check (value ) && Py_TYPE (value )-> tp_repr == PyType_Type .tp_repr
1309- && ((PyTypeObject * )value )-> tp_name != NULL ) {
1310- value_repr = PyUnicode_FromString (((PyTypeObject * )value )-> tp_name );
1311- Py_DECREF (value );
1312- }
1313- else {
1314- value_repr = PyObject_Repr (value );
1315- Py_DECREF (value );
1316- if (value_repr == NULL ) {
1317- PyErr_Clear ();
1318- value_repr = PyUnicode_FromString ("<value repr() failed>" );
1319- }
1320- }
1321- if (value_repr == NULL ) {
1322- // PyUnicode_FromString failed
1323- Py_ReprLeave (self );
1324- return NULL ;
1325- }
1326- PyObject * result = NULL ;
1327- if (ta -> type_params != NULL ) {
1328- _PyUnicodeWriter writer ;
1329- _PyUnicodeWriter_Init (& writer );
1330- PyTupleObject * type_params = (PyTupleObject * )ta -> type_params ;
1331- Py_ssize_t count = PyTuple_GET_SIZE (type_params );
1332- PyInterpreterState * interp = PyInterpreterState_Get ();
1333- for (Py_ssize_t i = 0 ; i < count ; i ++ ) {
1334- PyObject * type_param = PyTuple_GET_ITEM (type_params , i );
1335- if (i > 0 && _PyUnicodeWriter_WriteASCIIString (& writer , ", " , 2 ) < 0 ) {
1336- _PyUnicodeWriter_Dealloc (& writer );
1337- goto error ;
1338- }
1339- if (Py_IS_TYPE (type_param , interp -> cached_objects .paramspec_type )) {
1340- if (_PyUnicodeWriter_WriteASCIIString (& writer , "**" , 2 ) < 0 ) {
1341- _PyUnicodeWriter_Dealloc (& writer );
1342- goto error ;
1343- }
1344- }
1345- else if (Py_IS_TYPE (type_param , interp -> cached_objects .typevartuple_type )) {
1346- if (_PyUnicodeWriter_WriteASCIIString (& writer , "*" , 1 ) < 0 ) {
1347- _PyUnicodeWriter_Dealloc (& writer );
1348- goto error ;
1349- }
1350- }
1351- PyObject * type_param_repr = PyObject_Repr (type_param );
1352- if (type_param_repr == NULL ) {
1353- _PyUnicodeWriter_Dealloc (& writer );
1354- goto error ;
1355- }
1356- if (_PyUnicodeWriter_WriteStr (& writer , type_param_repr ) < 0 ) {
1357- Py_DECREF (type_param_repr );
1358- _PyUnicodeWriter_Dealloc (& writer );
1359- goto error ;
1360- }
1361- Py_DECREF (type_param_repr );
1362- }
1363- PyObject * params_repr = _PyUnicodeWriter_Finish (& writer );
1364- if (params_repr == NULL ) {
1365- goto error ;
1366- }
1367- result = PyUnicode_FromFormat ("<type alias %s[%U]: %U>" , ta -> name , params_repr , value_repr );
1368- Py_DECREF (params_repr );
1369- }
1370- else {
1371- result = PyUnicode_FromFormat ("<type alias %s: %U>" , ta -> name , value_repr );
1372- }
1373- error :
1374- Py_ReprLeave (self );
1375- Py_DECREF (value_repr );
1376- return result ;
1293+ return PyUnicode_FromString (ta -> name );
13771294}
13781295
13791296static PyMemberDef typealias_members [] = {
0 commit comments