mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
Issue #23502: The pprint module now supports mapping proxies.
In particular the __dict__ attributes of building types.
This commit is contained in:
parent
022f20376a
commit
87eb482e30
3 changed files with 40 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue