summaryrefslogtreecommitdiffstats
path: root/Lib/pprint.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 43b6b0d..8bbc845 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -131,6 +131,10 @@ class PrettyPrinter:
sepLines = _len(rep) > (self._width - 1 - indent - allowance)
write = stream.write
+ if self._depth and level > self._depth:
+ write(rep)
+ return
+
if sepLines:
r = getattr(typ, "__repr__", None)
if issubclass(typ, dict) and r is dict.__repr__:
@@ -252,7 +256,7 @@ def _safe_repr(object, context, maxlevels, level):
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
@@ -294,7 +298,7 @@ def _safe_repr(object, context, maxlevels, level):
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