Mercurial > cpython-lru_cache-weakref
diff Lib/pprint.py @ 46947:07a53bb82baa legacy-trunk
#1713041: fix pprint's handling of maximum depth.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Mon, 12 May 2008 16:26:52 +0000 |
| parents | 757a7f31e460 |
| children | 016166b7b976 |
line wrap: on
line diff
--- a/Lib/pprint.py Mon May 12 14:00:01 2008 +0000 +++ b/Lib/pprint.py Mon May 12 16:26:52 2008 +0000 @@ -131,6 +131,10 @@ sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write + if self._depth and level > self._depth: + write(rep) + return + r = getattr(typ, "__repr__", None) if issubclass(typ, dict) and r is dict.__repr__: write('{') @@ -211,9 +215,9 @@ write(',') write(endchar) return + write(rep) - def _repr(self, object, context, level): repr, readable, recursive = self.format(object, context.copy(), self._depth, level) @@ -259,7 +263,7 @@ if not object: return "{}", True, False objid = _id(object) - if maxlevels and level > maxlevels: + if maxlevels and level >= maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True @@ -293,7 +297,7 @@ return "()", True, False format = "(%s)" objid = _id(object) - if maxlevels and level > maxlevels: + if maxlevels and level >= maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True
