summaryrefslogtreecommitdiffstats
path: root/Lib/pprint.py
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2021-07-19 09:19:02 (GMT)
committerGitHub <noreply@github.com>2021-07-19 09:19:02 (GMT)
commitaab1899c9d79083c1ff31d974ed8b562d3ca3b5d (patch)
treed243fa6ada2ea05367737fe9a35573409df6e5a5 /Lib/pprint.py
parent2c2055884420f22afb4d2045bbdab7aa1394cb63 (diff)
downloadcpython-aab1899c9d79083c1ff31d974ed8b562d3ca3b5d.zip
cpython-aab1899c9d79083c1ff31d974ed8b562d3ca3b5d.tar.gz
cpython-aab1899c9d79083c1ff31d974ed8b562d3ca3b5d.tar.bz2
bpo-41546: make pprint (like print) not write to stdout when it is None (GH-26810)
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 13819f3..60ce57e 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -148,8 +148,9 @@ class PrettyPrinter:
self._underscore_numbers = underscore_numbers
def pprint(self, object):
- self._format(object, self._stream, 0, 0, {}, 0)
- self._stream.write("\n")
+ if self._stream is not None:
+ self._format(object, self._stream, 0, 0, {}, 0)
+ self._stream.write("\n")
def pformat(self, object):
sio = _StringIO()