[New-bugs-announce] [issue21185] heapq fails to print in sorted order for certain inputs

wchlm report at bugs.python.org
Wed Apr 9 10:06:33 CEST 2014


New submission from wchlm:

I observe the following in Python 2.6.1 in CentOS 5.9 and in Python 2.7.5 in MacOS 10.9.2.

A heapified 3-element array containing elements in the order [low, high, medium] fails to print in sorted order, as shown below: 

>>> import heapq
>>> lista = [1, 6, 5, 4]
>>> heapq.heapify(lista)
>>> lista # Gives sorted order, as expected
[1, 4, 5, 6]
>>> 
>>> listb = [1, 6, 5]
>>> heapq.heapify(listb)
>>> listb # Gives unsorted order -- unexpected and presumably a bug
[1, 6, 5]
>>> 
>>> [heapq.heappop(listb) for i in range(len(listb))] # But heappop works
[1, 5, 6]

----------
components: Devguide
messages: 215805
nosy: ezio.melotti, wchlm
priority: normal
severity: normal
status: open
title: heapq fails to print in sorted order for certain inputs
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21185>
_______________________________________


More information about the New-bugs-announce mailing list