##// END OF EJS Templates
Python 3 compatibility in IPython.lib.pretty
Thomas Kluyver -
Show More
@@ -454,8 +454,10 b' class GroupQueue(object):'
454 454 except ValueError:
455 455 pass
456 456
457
457 try:
458 458 _baseclass_reprs = (object.__repr__, types.InstanceType.__repr__)
459 except AttributeError: # Python 3
460 _baseclass_reprs = (object.__repr__,)
459 461
460 462
461 463 def _default_pprint(obj, p, cycle):
@@ -648,23 +650,33 b' _type_pprinters = {'
648 650 tuple: _seq_pprinter_factory('(', ')', tuple),
649 651 list: _seq_pprinter_factory('[', ']', list),
650 652 dict: _dict_pprinter_factory('{', '}', dict),
651 types.DictProxyType: _dict_pprinter_factory('<dictproxy {', '}>'),
653
652 654 set: _seq_pprinter_factory('set([', '])', set),
653 655 frozenset: _seq_pprinter_factory('frozenset([', '])', frozenset),
654 656 super: _super_pprint,
655 657 _re_pattern_type: _re_pattern_pprint,
656 658 type: _type_pprint,
657 types.ClassType: _type_pprint,
658 659 types.FunctionType: _function_pprint,
659 660 types.BuiltinFunctionType: _function_pprint,
660 661 types.SliceType: _repr_pprint,
661 662 types.MethodType: _repr_pprint,
662 xrange: _repr_pprint,
663
663 664 datetime.datetime: _repr_pprint,
664 665 datetime.timedelta: _repr_pprint,
665 666 _exception_base: _exception_pprint
666 667 }
667 668
669 try:
670 _type_pprinters[types.DictProxyType] = _dict_pprinter_factory('<dictproxy {', '}>')
671 _type_pprinters[types.ClassType] = _type_pprint,
672 except AttributeError: # Python 3
673 pass
674
675 try:
676 _type_pprinters[xrange] = _repr_pprint
677 except NameError:
678 _type_pprinters[range] = _repr_pprint
679
668 680 #: printers for types specified by name
669 681 _deferred_type_pprinters = {
670 682 }
General Comments 0
You need to be logged in to leave comments. Login now