summaryrefslogtreecommitdiffstats
path: root/Lib/pprint.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-24 17:31:50 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-24 17:31:50 (GMT)
commit87eb482e30ec76976e7c04b1547faaab0df40261 (patch)
tree14fe5585683be0734d33da68ea2f40f52686edca /Lib/pprint.py
parent022f20376a2458e0ecbd38e393957452570cd3a4 (diff)
downloadcpython-87eb482e30ec76976e7c04b1547faaab0df40261.zip
cpython-87eb482e30ec76976e7c04b1547faaab0df40261.tar.gz
cpython-87eb482e30ec76976e7c04b1547faaab0df40261.tar.bz2
Issue #23502: The pprint module now supports mapping proxies.
In particular the __dict__ attributes of building types.
Diffstat (limited to 'Lib/pprint.py')
-rw-r--r--Lib/pprint.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 5b65f57..9031a0b 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -36,6 +36,7 @@ saferepr()
import re
import sys as _sys
+import types as _types
from collections import OrderedDict as _OrderedDict
from io import StringIO as _StringIO
@@ -313,6 +314,14 @@ class PrettyPrinter:
_dispatch[bytearray.__repr__] = _pprint_bytearray
+ def _pprint_mappingproxy(self, object, stream, indent, allowance, context, level):
+ stream.write('mappingproxy(')
+ self._format(object.copy(), stream, indent + 13, allowance + 1,
+ context, level)
+ stream.write(')')
+
+ _dispatch[_types.MappingProxyType.__repr__] = _pprint_mappingproxy
+
def _format_dict_items(self, items, stream, indent, allowance, context,
level):
write = stream.write