From 5d64897b64afdb060ef360775480d61218768780 2023-10-06 15:01:07 From: Matthias Bussonnier Date: 2023-10-06 15:01:07 Subject: [PATCH] Remove try/except handing Python2 (#14204) --- diff --git a/IPython/lib/pretty.py b/IPython/lib/pretty.py index 3486450..2575c3b 100644 --- a/IPython/lib/pretty.py +++ b/IPython/lib/pretty.py @@ -841,17 +841,8 @@ _env_type = type(os.environ) if _env_type is not dict: _type_pprinters[_env_type] = _dict_pprinter_factory('environ{', '}') -try: - # In PyPy, types.DictProxyType is dict, setting the dictproxy printer - # using dict.setdefault avoids overwriting the dict printer - _type_pprinters.setdefault(types.DictProxyType, - _dict_pprinter_factory('dict_proxy({', '})')) - _type_pprinters[types.ClassType] = _type_pprint - _type_pprinters[types.SliceType] = _repr_pprint -except AttributeError: # Python 3 - _type_pprinters[types.MappingProxyType] = \ - _dict_pprinter_factory('mappingproxy({', '})') - _type_pprinters[slice] = _repr_pprint +_type_pprinters[types.MappingProxyType] = _dict_pprinter_factory("mappingproxy({", "})") +_type_pprinters[slice] = _repr_pprint _type_pprinters[range] = _repr_pprint _type_pprinters[bytes] = _repr_pprint