diff -r 34986f55a32d Lib/test/test_structseq.py --- a/Lib/test/test_structseq.py Sun Oct 20 17:25:34 2013 +0300 +++ b/Lib/test/test_structseq.py Mon Oct 21 01:12:12 2013 +0530 @@ -34,7 +34,8 @@ t = time.gmtime(0) self.assertEqual(repr(t), "time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, " - "tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)") + "tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0, " + "{tm_zone='GMT', tm_gmtoff=0})") # os.stat() gives a complicated struct sequence. st = os.stat(__file__) rep = repr(st) @@ -42,6 +43,7 @@ self.assertIn("st_mode=", rep) self.assertIn("st_ino=", rep) self.assertIn("st_dev=", rep) + self.assertIn("st_blksize=", rep) def test_concat(self): t1 = time.gmtime() diff -r 34986f55a32d Objects/structseq.c --- a/Objects/structseq.c Sun Oct 20 17:25:34 2013 +0300 +++ b/Objects/structseq.c Mon Oct 21 01:12:12 2013 +0530 @@ -165,7 +165,7 @@ PyTypeObject *typ = Py_TYPE(obj); int i, removelast = 0; - Py_ssize_t len; + Py_ssize_t len, n_visible_fields = VISIBLE_SIZE(obj); char buf[REPR_BUFFER_SIZE]; char *endofbuf, *pbuf = buf; @@ -179,7 +179,7 @@ pbuf += len; *pbuf++ = '('; - for (i=0; i < VISIBLE_SIZE(obj); i++) { + for (i = 0; i < REAL_SIZE(obj) - UNNAMED_FIELDS(obj); i++) { PyObject *val, *repr; char *cname, *crepr; @@ -201,7 +201,14 @@ /* + 3: keep space for "=" and ", " */ len = strlen(cname) + strlen(crepr) + 3; + if (i == n_visible_fields) { + /* We need space for {} */ + len += 2; + } if ((pbuf+len) <= endofbuf) { + if (i == n_visible_fields) { + *pbuf++ = '{'; + } strcpy(pbuf, cname); pbuf += strlen(cname); *pbuf++ = '='; @@ -224,6 +231,9 @@ /* overwrite last ", " */ pbuf-=2; } + if (i > n_visible_fields) { + *pbuf++ = '}'; + } *pbuf++ = ')'; *pbuf = '\0';