diff -r b8d108a2a38e Doc/c-api/exceptions.rst --- a/Doc/c-api/exceptions.rst Fri Dec 25 21:05:35 2015 +0200 +++ b/Doc/c-api/exceptions.rst Sat Dec 26 15:36:07 2015 +0200 @@ -708,9 +708,7 @@ these are the C equivalent to :func:`rep If the object has already been processed, the function returns a positive integer. In that case the :c:member:`~PyTypeObject.tp_repr` implementation - should return a string object indicating a cycle. As examples, - :class:`dict` objects return ``{...}`` and :class:`list` objects - return ``[...]``. + should return a string object indicating a cycle (usually ``<...>``). The function will return a negative integer if the recursion limit is reached. In that case the :c:member:`~PyTypeObject.tp_repr` implementation should diff -r b8d108a2a38e Doc/library/pprint.rst --- a/Doc/library/pprint.rst Fri Dec 25 21:05:35 2015 +0200 +++ b/Doc/library/pprint.rst Sat Dec 26 15:36:07 2015 +0200 @@ -41,7 +41,7 @@ The :mod:`pprint` module defines one cla the default is one. Other values can cause output to look a little odd, but can make nesting easier to spot. The number of levels which may be printed is controlled by *depth*; if the data structure being printed is too deep, the next - contained level is replaced by ``...``. By default, there is no constraint on + contained level is replaced by ``<...>``. By default, there is no constraint on the depth of the objects being formatted. The desired output width is constrained using the *width* parameter; the default is 80 characters. If a structure cannot be formatted within the constrained width, a best effort will @@ -73,7 +73,7 @@ The :mod:`pprint` module defines one cla ... ('parrot', ('fresh fruit',)))))))) >>> pp = pprint.PrettyPrinter(depth=6) >>> pp.pprint(tup) - ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...))))))) + ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', <...>)))))) The :mod:`pprint` module also provides several shortcut functions: @@ -287,7 +287,7 @@ contents):: 'cheesecake_code_kwalitee_id': None, 'cheesecake_documentation_id': None, 'cheesecake_installability_id': None, - 'classifiers': [...], + 'classifiers': <...>, 'description': 'An extensible framework for Python programming, with ' 'special focus\r\n' 'on event-based network programming and multiprotocol ' @@ -307,7 +307,7 @@ contents):: 'stable_version': None, 'summary': 'An asynchronous networking framework written in Python', 'version': '12.3.0'}, - 'urls': [{...}, {...}]} + 'urls': [<...>, <...>]} Additionally, maximum character *width* can be suggested. If a long object cannot be split, the specified width will be exceeded:: @@ -321,7 +321,7 @@ cannot be split, the specified width wil 'cheesecake_code_kwalitee_id': None, 'cheesecake_documentation_id': None, 'cheesecake_installability_id': None, - 'classifiers': [...], + 'classifiers': <...>, 'description': 'An extensible ' 'framework for Python ' 'programming, with ' @@ -347,4 +347,4 @@ cannot be split, the specified width wil 'framework written in ' 'Python', 'version': '12.3.0'}, - 'urls': [{...}, {...}]} + 'urls': [<...>, <...>]} diff -r b8d108a2a38e Doc/library/reprlib.rst --- a/Doc/library/reprlib.rst Fri Dec 25 21:05:35 2015 +0200 +++ b/Doc/library/reprlib.rst Sat Dec 26 15:36:07 2015 +0200 @@ -41,7 +41,7 @@ In addition to size-limiting tools, the detecting recursive calls to :meth:`__repr__` and substituting a placeholder string instead. -.. decorator:: recursive_repr(fillvalue="...") +.. decorator:: recursive_repr(fillvalue="<...>") Decorator for :meth:`__repr__` methods to detect recursive calls within the same thread. If a recursive call is made, the *fillvalue* is returned, @@ -56,10 +56,13 @@ string instead. >>> m.append(m) >>> m.append('x') >>> print(m) - <'a'|'b'|'c'|...|'x'> + <'a'|'b'|'c'|<...>|'x'> .. versionadded:: 3.2 + .. versionchanged:: 3.6 + The default *fillvalue* is now ``"<...>"``. + .. _repr-objects: diff -r b8d108a2a38e Lib/pprint.py --- a/Lib/pprint.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/pprint.py Sat Dec 26 15:36:07 2015 +0200 @@ -498,7 +498,7 @@ def _safe_repr(object, context, maxlevel return "{}", True, False objid = id(object) if maxlevels and level >= maxlevels: - return "{...}", False, objid in context + return "<...>", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 @@ -533,7 +533,7 @@ def _safe_repr(object, context, maxlevel format = "(%s)" objid = id(object) if maxlevels and level >= maxlevels: - return format % "...", False, objid in context + return "<...>", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 diff -r b8d108a2a38e Lib/reprlib.py --- a/Lib/reprlib.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/reprlib.py Sat Dec 26 15:36:07 2015 +0200 @@ -9,7 +9,7 @@ try: except ImportError: from _dummy_thread import get_ident -def recursive_repr(fillvalue='...'): +def recursive_repr(fillvalue='<...>'): 'Decorator to make a repr function return fillvalue for a recursive call' def decorating_function(user_function): @@ -66,14 +66,14 @@ class Repr: def _repr_iterable(self, x, level, left, right, maxiter, trail=''): n = len(x) if level <= 0 and n: - s = '...' + return '<...>' else: newlevel = level - 1 repr1 = self.repr1 pieces = [repr1(elem, newlevel) for elem in islice(x, maxiter)] - if n > maxiter: pieces.append('...') + if n > maxiter: pieces.append('...') s = ', '.join(pieces) if n == 1 and trail: right = trail + right return '%s%s%s' % (left, s, right) def repr_tuple(self, x, level): @@ -107,7 +107,7 @@ class Repr: def repr_dict(self, x, level): n = len(x) if n == 0: return '{}' - if level <= 0: return '{...}' + if level <= 0: return '<...>' newlevel = level - 1 repr1 = self.repr1 pieces = [] diff -r b8d108a2a38e Lib/test/list_tests.py --- a/Lib/test/list_tests.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/list_tests.py Sat Dec 26 15:36:07 2015 +0200 @@ -50,8 +50,8 @@ class CommonTest(seq_tests.CommonTest): a2.append(a2) a2.append(3) - self.assertEqual(str(a2), "[0, 1, 2, [...], 3]") - self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]") + self.assertEqual(str(a2), "[0, 1, 2, <...>, 3]") + self.assertEqual(repr(a2), "[0, 1, 2, <...>, 3]") l0 = [] for i in range(sys.getrecursionlimit() + 100): diff -r b8d108a2a38e Lib/test/mapping_tests.py --- a/Lib/test/mapping_tests.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/mapping_tests.py Sat Dec 26 15:36:07 2015 +0200 @@ -608,7 +608,7 @@ class TestHashMappingProtocol(TestMappin self.assertEqual(repr(d), '{1: 2}') d = self._empty_mapping() d[1] = d - self.assertEqual(repr(d), '{1: {...}}') + self.assertEqual(repr(d), '{1: <...>}') class Exc(Exception): pass diff -r b8d108a2a38e Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_builtin.py Sat Dec 26 15:36:07 2015 +0200 @@ -210,10 +210,10 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(ascii({}), '{}') a = [] a.append(a) - self.assertEqual(ascii(a), '[[...]]') + self.assertEqual(ascii(a), '[<...>]') a = {} a[0] = a - self.assertEqual(ascii(a), '{0: {...}}') + self.assertEqual(ascii(a), '{0: <...>}') # Advanced checks for unicode strings def _check_uni(s): self.assertEqual(ascii(s), repr(s)) @@ -1144,10 +1144,10 @@ class BuiltinTest(unittest.TestCase): self.assertEqual(repr({}), '{}') a = [] a.append(a) - self.assertEqual(repr(a), '[[...]]') + self.assertEqual(repr(a), '[<...>]') a = {} a[0] = a - self.assertEqual(repr(a), '{0: {...}}') + self.assertEqual(repr(a), '{0: <...>}') def test_round(self): self.assertEqual(round(0.0), 0.0) diff -r b8d108a2a38e Lib/test/test_defaultdict.py --- a/Lib/test/test_defaultdict.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_defaultdict.py Sat Dec 26 15:36:07 2015 +0200 @@ -158,7 +158,7 @@ class TestDefaultDict(unittest.TestCase) d = sub() self.assertRegex(repr(d), r"defaultdict\(, \{\}\)") + r"of defaultdict\(<\.\.\.>, \{\}\)>, \{\}\)") # NOTE: printing a subclass of a builtin type does not call its # tp_print slot. So this part is essentially the same test as above. diff -r b8d108a2a38e Lib/test/test_dict.py --- a/Lib/test/test_dict.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_dict.py Sat Dec 26 15:36:07 2015 +0200 @@ -454,7 +454,7 @@ class DictTest(unittest.TestCase): self.assertEqual(repr(d), '{1: 2}') d = {} d[1] = d - self.assertEqual(repr(d), '{1: {...}}') + self.assertEqual(repr(d), '{1: <...>}') class Exc(Exception): pass diff -r b8d108a2a38e Lib/test/test_ordered_dict.py --- a/Lib/test/test_ordered_dict.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_ordered_dict.py Sat Dec 26 15:36:07 2015 +0200 @@ -327,7 +327,7 @@ class OrderedDictTests: od = OrderedDict.fromkeys('abc') od['x'] = od self.assertEqual(repr(od), - "OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)])") + "OrderedDict([('a', None), ('b', None), ('c', None), ('x', <...>)])") def test_setdefault(self): OrderedDict = self.OrderedDict diff -r b8d108a2a38e Lib/test/test_pprint.py --- a/Lib/test/test_pprint.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_pprint.py Sat Dec 26 15:36:07 2015 +0200 @@ -611,9 +611,9 @@ frozenset2({0, self.assertEqual(pprint.pformat(nested_dict), repr(nested_dict)) self.assertEqual(pprint.pformat(nested_list), repr(nested_list)) - lv1_tuple = '(1, (...))' - lv1_dict = '{1: {...}}' - lv1_list = '[1, [...]]' + lv1_tuple = '(1, <...>)' + lv1_dict = '{1: <...>}' + lv1_list = '[1, <...>]' self.assertEqual(pprint.pformat(nested_tuple, depth=1), lv1_tuple) self.assertEqual(pprint.pformat(nested_dict, depth=1), lv1_dict) self.assertEqual(pprint.pformat(nested_list, depth=1), lv1_list) diff -r b8d108a2a38e Lib/test/test_reprlib.py --- a/Lib/test/test_reprlib.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_reprlib.py Sat Dec 26 15:36:07 2015 +0200 @@ -167,18 +167,18 @@ class ReprTests(unittest.TestCase): eq = self.assertEqual # everything is meant to give up after 6 levels. eq(r([[[[[[[]]]]]]]), "[[[[[[[]]]]]]]") - eq(r([[[[[[[[]]]]]]]]), "[[[[[[[...]]]]]]]") + eq(r([[[[[[[[]]]]]]]]), "[[[[[[<...>]]]]]]") eq(r(nestedTuple(6)), "(((((((),),),),),),)") - eq(r(nestedTuple(7)), "(((((((...),),),),),),)") + eq(r(nestedTuple(7)), "((((((<...>,),),),),),)") eq(r({ nestedTuple(5) : nestedTuple(5) }), "{((((((),),),),),): ((((((),),),),),)}") eq(r({ nestedTuple(6) : nestedTuple(6) }), - "{((((((...),),),),),): ((((((...),),),),),)}") + "{(((((<...>,),),),),): (((((<...>,),),),),)}") eq(r([[[[[[{}]]]]]]), "[[[[[[{}]]]]]]") - eq(r([[[[[[[{}]]]]]]]), "[[[[[[[...]]]]]]]") + eq(r([[[[[[[{}]]]]]]]), "[[[[[[<...>]]]]]]") def test_cell(self): def get_cell(): @@ -380,7 +380,7 @@ class TestRecursiveRepr(unittest.TestCas m.append(m) m.append('x') m.append(m) - self.assertEqual(repr(m), '') + self.assertEqual(repr(m), ', x, <...>>') m = MyContainer2(list('abcde')) m.append(m) m.append('x') diff -r b8d108a2a38e Lib/test/test_set.py --- a/Lib/test/test_set.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_set.py Sat Dec 26 15:36:07 2015 +0200 @@ -314,10 +314,10 @@ class TestJointOps: s = self.thetype([w]) w.value = s if self.thetype == set: - self.assertEqual(repr(s), '{set(...)}') + self.assertEqual(repr(s), '{<...>}') else: name = repr(s).partition('(')[0] # strip class name - self.assertEqual(repr(s), '%s({%s(...)})' % (name, name)) + self.assertEqual(repr(s), '%s({<...>})' % (name,)) def test_cyclical_print(self): w = ReprWrapper() diff -r b8d108a2a38e Lib/test/test_types.py --- a/Lib/test/test_types.py Fri Dec 25 21:05:35 2015 +0200 +++ b/Lib/test/test_types.py Sat Dec 26 15:36:07 2015 +0200 @@ -1133,8 +1133,8 @@ class SimpleNamespaceTests(unittest.Test ns2.spam = ns3 ns3.spam = ns2 name = "namespace" - repr1 = "{name}(c='cookie', spam={name}(...))".format(name=name) - repr2 = "{name}(spam={name}(spam={name}(...), x=1))".format(name=name) + repr1 = "{name}(c='cookie', spam=<...>)".format(name=name) + repr2 = "{name}(spam={name}(spam=<...>, x=1))".format(name=name) self.assertEqual(repr(ns1), repr1) self.assertEqual(repr(ns2), repr2) diff -r b8d108a2a38e Modules/_collectionsmodule.c --- a/Modules/_collectionsmodule.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Modules/_collectionsmodule.c Sat Dec 26 15:36:07 2015 +0200 @@ -1337,7 +1337,7 @@ deque_repr(PyObject *deque) if (i != 0) { if (i < 0) return NULL; - return PyUnicode_FromString("[...]"); + return PyUnicode_FromString("<...>"); } aslist = PySequence_List(deque); @@ -2075,7 +2075,7 @@ defdict_repr(defdictobject *dd) Py_DECREF(baserepr); return NULL; } - defrepr = PyUnicode_FromString("..."); + defrepr = PyUnicode_FromString("<...>"); } else defrepr = PyObject_Repr(dd->default_factory); diff -r b8d108a2a38e Modules/_operator.c --- a/Modules/_operator.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Modules/_operator.c Sat Dec 26 15:36:07 2015 +0200 @@ -495,7 +495,7 @@ itemgetter_repr(itemgetterobject *ig) if (status != 0) { if (status < 0) return NULL; - return PyUnicode_FromFormat("%s(...)", Py_TYPE(ig)->tp_name); + return PyUnicode_FromString("<...>"); } reprfmt = ig->nitems == 1 ? "%s(%R)" : "%s%R"; @@ -819,7 +819,7 @@ attrgetter_repr(attrgetterobject *ag) if (status != 0) { if (status < 0) return NULL; - return PyUnicode_FromFormat("%s(...)", Py_TYPE(ag)->tp_name); + return PyUnicode_FromString("<...>"); } if (ag->nattrs == 1) { @@ -1007,7 +1007,7 @@ methodcaller_repr(methodcallerobject *mc if (status != 0) { if (status < 0) return NULL; - return PyUnicode_FromFormat("%s(...)", Py_TYPE(mc)->tp_name); + return PyUnicode_FromString("<...>"); } if (mc->kwds != NULL) { diff -r b8d108a2a38e Objects/dictobject.c --- a/Objects/dictobject.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Objects/dictobject.c Sat Dec 26 15:36:07 2015 +0200 @@ -1624,7 +1624,7 @@ dict_repr(PyDictObject *mp) i = Py_ReprEnter((PyObject *)mp); if (i != 0) { - return i > 0 ? PyUnicode_FromString("{...}") : NULL; + return i > 0 ? PyUnicode_FromString("<...>") : NULL; } if (mp->ma_used == 0) { diff -r b8d108a2a38e Objects/listobject.c --- a/Objects/listobject.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Objects/listobject.c Sat Dec 26 15:36:07 2015 +0200 @@ -347,7 +347,7 @@ list_repr(PyListObject *v) i = Py_ReprEnter((PyObject*)v); if (i != 0) { - return i > 0 ? PyUnicode_FromString("[...]") : NULL; + return i > 0 ? PyUnicode_FromString("<...>") : NULL; } _PyUnicodeWriter_Init(&writer); diff -r b8d108a2a38e Objects/namespaceobject.c --- a/Objects/namespaceobject.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Objects/namespaceobject.c Sat Dec 26 15:36:07 2015 +0200 @@ -79,7 +79,7 @@ namespace_repr(PyObject *ns) i = Py_ReprEnter(ns); if (i != 0) { - return i > 0 ? PyUnicode_FromFormat("%s(...)", name) : NULL; + return i > 0 ? PyUnicode_FromString("<...>") : NULL; } pairs = PyList_New(0); diff -r b8d108a2a38e Objects/odictobject.c --- a/Objects/odictobject.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Objects/odictobject.c Sat Dec 26 15:36:07 2015 +0200 @@ -1490,7 +1490,7 @@ odict_repr(PyODictObject *self) i = Py_ReprEnter((PyObject *)self); if (i != 0) { - return i > 0 ? PyUnicode_FromString("...") : NULL; + return i > 0 ? PyUnicode_FromString("<...>") : NULL; } if (PyODict_CheckExact(self)) { diff -r b8d108a2a38e Objects/setobject.c --- a/Objects/setobject.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Objects/setobject.c Sat Dec 26 15:36:07 2015 +0200 @@ -586,7 +586,7 @@ set_repr(PySetObject *so) if (status != 0) { if (status < 0) return NULL; - return PyUnicode_FromFormat("%s(...)", Py_TYPE(so)->tp_name); + return PyUnicode_FromString("<...>"); } /* shortcut for the empty set */ diff -r b8d108a2a38e Objects/tupleobject.c --- a/Objects/tupleobject.c Fri Dec 25 21:05:35 2015 +0200 +++ b/Objects/tupleobject.c Sat Dec 26 15:36:07 2015 +0200 @@ -267,7 +267,7 @@ tuplerepr(PyTupleObject *v) possible within a type. */ i = Py_ReprEnter((PyObject *)v); if (i != 0) { - return i > 0 ? PyUnicode_FromString("(...)") : NULL; + return i > 0 ? PyUnicode_FromString("<...>") : NULL; } _PyUnicodeWriter_Init(&writer);