[issue14998] pprint._safe_key is not always safe enough

2012-07-21 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 03cda5360dc6 by Florent Xicluna in branch '3.2':
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with 
unorderable key.
http://hg.python.org/cpython/rev/03cda5360dc6

New changeset 4d0dcfbdf45b by Florent Xicluna in branch 'default':
Issues #10017 and #14998: Fix TypeError using pprint on dictionaries with 
unorderable key.
http://hg.python.org/cpython/rev/4d0dcfbdf45b

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-07-21 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

Thank you for this patch.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-07-21 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

I just broke tests :(

--
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-07-21 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

Test test_pprint fixed with changesets 29642f82bbcc and 79d44f4920d9.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-06-15 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti
stage: needs patch - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-06-07 Thread Shawn Brown

Shawn Brown 03sjbr...@gmail.com added the comment:

Here's a patch for 3.3 -- as well as two new assertions in test_pprint.py

The added try/catch also fixes the issues mentioned in issue 10017 so I added a 
test for that case as well.

--
keywords: +patch
Added file: http://bugs.python.org/file25864/pprint_safe_key.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-06-04 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
nosy: +flox

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-06-04 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +rhettinger
stage:  - needs patch
type:  - behavior
versions: +Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14998] pprint._safe_key is not always safe enough

2012-06-03 Thread Shawn Brown

New submission from Shawn Brown 03sjbr...@gmail.com:

This is related to resolved issue 3976 and, to a lesser extent, issue 10017.

I've run across another instance where pprint throws an exception (but works 
fine in 2.7 and earlier):

Python 3.2 (r32:88445, Mar 25 2011, 19:28:28) 
[GCC 4.5.2] on linux2
Type help, copyright, credits or license for more information.
 from pprint import pprint
 pprint({(0,): 1, (None,): 2})
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python3.2/pprint.py, line 55, in pprint
printer.pprint(object)
  File /usr/lib/python3.2/pprint.py, line 132, in pprint
self._format(object, self._stream, 0, 0, {}, 0)
  File /usr/lib/python3.2/pprint.py, line 155, in _format
rep = self._repr(object, context, level - 1)
  File /usr/lib/python3.2/pprint.py, line 245, in _repr
self._depth, level)
  File /usr/lib/python3.2/pprint.py, line 257, in format
return _safe_repr(object, context, maxlevels, level)
  File /usr/lib/python3.2/pprint.py, line 299, in _safe_repr
items = sorted(object.items(), key=_safe_tuple)
  File /usr/lib/python3.2/pprint.py, line 89, in __lt__
rv = self.obj.__lt__(other.obj)
TypeError: unorderable types: int()  NoneType()

The above example might seem contrived but I stumbled across the issue quite 
naturally. Honest!

In working with multiple lists and computing results using combinations of 
these lists' values.  I _could_ organize the results as a dictionary of 
dictionaries of dictionaries but that would get confusing very quickly.  
Instead, I'm using a single dictionary with a composite key (flat is better 
than nested). So I've got code like this...

 combinations = itertools.product(lst_x, lst_y, lst_z)
 results = {(x,y,z): compute(x,y,z) for x,y,z in combinations}

... and it is not uncommon for one or more of the values to be None -- 
resulting in the above exception should anyone (including unittest) attempt to 
pprint the dictionary.

--
components: Library (Lib)
messages: 162249
nosy: Shawn.Brown
priority: normal
severity: normal
status: open
title: pprint._safe_key is not always safe enough
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14998
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com