From ca9e56dd0158cd7dd732c656ded88e1449342ad1 2016-07-29 21:58:56 From: Danilo J. S. Bellini Date: 2016-07-29 21:58:56 Subject: [PATCH] Fix dict pretty printer in PyPy #9776 +3 tests passing --- diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py index 49ee2ce..8cb51aa 100644 --- a/IPython/lib/pretty.py +++ b/IPython/lib/pretty.py @@ -753,7 +753,10 @@ _type_pprinters = { } try: - _type_pprinters[types.DictProxyType] = _dict_pprinter_factory('') + # In PyPy, types.DictProxyType is dict, setting the dictproxy printer + # using dict.setdefault avoids overwritting the dict printer + _type_pprinters.setdefault(types.DictProxyType, + _dict_pprinter_factory('')) _type_pprinters[types.ClassType] = _type_pprint _type_pprinters[types.SliceType] = _repr_pprint except AttributeError: # Python 3