[issue3976] pprint._safe_repr is not general enough in one instance

2010-10-08 Thread Rodrigo Bernardo Pimentel
Rodrigo Bernardo Pimentel added the comment: Armin: this has the problem that, if the object you're trying to compare is a class, self.obj.__lt__ expects a different number of parameters (i.e., it expects the instance). See issue 10017 . Testing with "<" works. -- nosy: +rbp

[issue3976] pprint._safe_repr is not general enough in one instance

2009-11-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: Fixed. See r76389 and r76390. -- resolution: -> fixed status: open -> closed ___ Python tracker ___ ___

[issue3976] pprint._safe_repr is not general enough in one instance

2009-11-18 Thread David W. Lambert
Changes by David W. Lambert : -- nosy: +LambertDW ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue3976] pprint._safe_repr is not general enough in one instance

2009-09-20 Thread Armin Ronacher
Armin Ronacher added the comment: Eg, something like this: class safe_key(object): __slots__ = ('obj',) def __init__(self, obj): self.obj = obj def __eq__(self, other): return self.obj.__eq__(other.obj) def __lt__(self, other): rv = self.obj.__lt__(ot

[issue3976] pprint._safe_repr is not general enough in one instance

2009-09-20 Thread Armin Ronacher
Armin Ronacher added the comment: @Georg: Instead of catching a TypeError i would rather call __gt__ / __lt__ directly and check for NotImplemented. Python 2.x did not catch TypeErrors either. -- ___ Python tracker

[issue3976] pprint._safe_repr is not general enough in one instance

2009-09-20 Thread Georg Brandl
Georg Brandl added the comment: OK, there *is* a way. Consider this: class safe_key(object): __slots__ = ('obj',) def __init__(self, obj): self.obj = obj def __eq__(self, other): return self.obj.__eq__(other.obj) def __lt__(self, other): try:

[issue3976] pprint._safe_repr is not general enough in one instance

2009-09-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: I'm thinking that pprint should not try to sort unsortable items. try: items = sorted(items) except TypeError: items = list(items) -- assignee: -> rhettinger nosy: +rhettinger versions: +Python 3.1, Python 3.2 -Python 3.0 _

[issue3976] pprint._safe_repr is not general enough in one instance

2009-09-20 Thread Georg Brandl
Georg Brandl added the comment: Also note that this patch will not sort sequences of mixed types where some types are intercomparable "correctly" (in the way that Python 2 did), e.g. for {1:2, 2:3, 'a':4, 1.5: 5} the 1.5 key will not be placed between the 1 and 2 keys. I'm not aware of a way

[issue3976] pprint._safe_repr is not general enough in one instance

2009-09-20 Thread Armin Ronacher
Changes by Armin Ronacher : -- nosy: +aronacher ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyth

[issue3976] pprint._safe_repr is not general enough in one instance

2009-02-04 Thread Robert Kern
Changes by Robert Kern : -- nosy: +robert.kern ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue3976] pprint._safe_repr is not general enough in one instance

2009-01-06 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: The proposed patch appears to give up sorting by key,value altogether if there are a few incomparable items. It would be better to group items by type and sort within each group. For example, pprint({1:1,2:2,A():3,A():4}) should print int:int items in

[issue3976] pprint._safe_repr is not general enough in one instance

2008-12-31 Thread Antoine Pitrou
Antoine Pitrou added the comment: For this to be integrated, it should also add an unit test. ___ Python tracker ___ ___ Python-bugs-list maili

[issue3976] pprint._safe_repr is not general enough in one instance

2008-09-26 Thread Erick Tryzelaar
Erick Tryzelaar <[EMAIL PROTECTED]> added the comment: fyi, I found another case where pprint needs a "safe sort", this is when you have a list that contains a dictionary. Anyway, Here's a simple patch that creates a _safe_sorted function that implements the fallback: --- /opt/local/lib/python3.

[issue3976] pprint._safe_repr is not general enough in one instance

2008-09-26 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: Another solution would be to separate the dict items by key type, try to sort each items list with separate fallback on onsorted. Then merge the whole thing, ordered by key type name. -- nosy: +pitrou

[issue3976] pprint._safe_repr is not general enough in one instance

2008-09-26 Thread Erick Tryzelaar
New submission from Erick Tryzelaar <[EMAIL PROTECTED]>: I've run into a case where pprint isn't able to print out a particular data structure, and have distilled it down to a simple example: import pprint class A: pass pprint.pprint({A(): 1, A(): 2}) Which throws this exception: Traceb