[issue20192] pprint chokes on set containing frozenset

2020-05-31 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Python 2.7 is no longer supported.

--
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20192] pprint chokes on set containing frozenset

2015-04-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is reproducible on 2.7 example:

 import pprint, datetime, test.test_datetime
 naive = datetime.datetime.utcnow()
 aware = 
 datetime.datetime.utcnow().replace(tzinfo=test.test_datetime.FixedOffset(-300,
  EST, 1))
 pprint.pprint({naive, aware})
set([Traceback (most recent call last):
  File stdin, line 1, in module
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 59, in pprint
printer.pprint(object)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 117, in pprint
self._format(object, self._stream, 0, 0, {}, 0)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 199, in _format
object = _sorted(object)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 82, in _sorted
return sorted(iterable)
TypeError: can't compare offset-naive and offset-aware datetimes
 pprint.pprint({naive: 'naive', aware: 'aware'})
Traceback (most recent call last):
  File stdin, line 1, in module
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 59, in pprint
printer.pprint(object)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 117, in pprint
self._format(object, self._stream, 0, 0, {}, 0)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 140, in _format
rep = self._repr(object, context, level - 1)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 226, in _repr
self._depth, level)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 238, in format
return _safe_repr(object, context, maxlevels, level)
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 280, in _safe_repr
for k, v in _sorted(object.items()):
  File /home/serhiy/py/cpython2.7/Lib/pprint.py, line 82, in _sorted
return sorted(iterable)
TypeError: can't compare offset-naive and offset-aware datetimes

--

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



[issue20192] pprint chokes on set containing frozenset

2014-12-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

For now sets and frozensets are comparable with other types in Python 2.

 frozenset(xrange(10))  1
False
 set(xrange(10))  1
False

The only known to me uncomparable types in Python 2 are naive and aware 
datetime.

--
nosy: +serhiy.storchaka

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



[issue20192] pprint chokes on set containing frozenset

2014-01-08 Thread Joseph Bylund

New submission from Joseph Bylund:

Expected: pprint the object
Observed: crash with:
set([Traceback (most recent call last):
  File ./test.py, line 7, in module
pp.pprint(myset)
  File /usr/lib/python2.7/pprint.py, line 117, in pprint
self._format(object, self._stream, 0, 0, {}, 0)
  File /usr/lib/python2.7/pprint.py, line 194, in _format
object = _sorted(object)
  File /usr/lib/python2.7/pprint.py, line 82, in _sorted
return sorted(iterable)
TypeError: can only compare to a set


Steps to repro:
#!/usr/bin/python
import pprint
pp = pprint.PrettyPrinter(indent=4)

myset = set(xrange(3))
myset.add(frozenset(xrange(10)))
pp.pprint(myset)

--
messages: 207693
nosy: jbylund
priority: normal
severity: normal
status: open
title: pprint chokes on set containing frozenset
type: crash
versions: Python 2.7

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



[issue20192] pprint chokes on set containing frozenset

2014-01-08 Thread R. David Murray

R. David Murray added the comment:

FYI, 'crash' is for when the CPython interpreter segfaults, not when python 
produces a traceback.

Sets and frozensets are not comparable to anything except themselves, unlike 
most other Python2 datatypes.  In Python3, most disparate types are not 
comparable, including sets and frozensets.

To fix this issue in 2.7's pprint I think we would have to backport the fix 
from issue 3976.

--
components: +Library (Lib)
nosy: +r.david.murray
type: crash - behavior

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