##// END OF EJS Templates
Find and replace newlines in __repr__ results
Remi Rampin -
Show More
@@ -517,11 +517,7 b' def _default_pprint(obj, p, cycle):'
517 klass = _safe_getattr(obj, '__class__', None) or type(obj)
517 klass = _safe_getattr(obj, '__class__', None) or type(obj)
518 if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs:
518 if _safe_getattr(klass, '__repr__', None) not in _baseclass_reprs:
519 # A user-provided repr. Find newlines and replace them with p.break_()
519 # A user-provided repr. Find newlines and replace them with p.break_()
520 output = repr(obj)
520 _repr_pprint(obj, p, cycle)
521 for idx,output_line in enumerate(output.splitlines()):
522 if idx:
523 p.break_()
524 p.text(output_line)
525 return
521 return
526 p.begin_group(1, '<')
522 p.begin_group(1, '<')
527 p.pretty(klass)
523 p.pretty(klass)
@@ -685,7 +681,7 b' def _type_pprint(obj, p, cycle):'
685
681
686 # Checks for a __repr__ override in the metaclass
682 # Checks for a __repr__ override in the metaclass
687 if type(obj).__repr__ is not type.__repr__:
683 if type(obj).__repr__ is not type.__repr__:
688 p.text(repr(obj))
684 _repr_pprint(obj, p, cycle)
689 return
685 return
690
686
691 mod = _safe_getattr(obj, '__module__', None)
687 mod = _safe_getattr(obj, '__module__', None)
@@ -699,7 +695,12 b' def _type_pprint(obj, p, cycle):'
699
695
700 def _repr_pprint(obj, p, cycle):
696 def _repr_pprint(obj, p, cycle):
701 """A pprint that just redirects to the normal repr function."""
697 """A pprint that just redirects to the normal repr function."""
702 p.text(repr(obj))
698 # Find newlines and replace them with p.break_()
699 output = repr(obj)
700 for idx,output_line in enumerate(output.splitlines()):
701 if idx:
702 p.break_()
703 p.text(output_line)
703
704
704
705
705 def _function_pprint(obj, p, cycle):
706 def _function_pprint(obj, p, cycle):
General Comments 0
You need to be logged in to leave comments. Login now