Issue 13274: heapq pure python version uses islice without guarding for negative counts (original ) (raw )Created on 2011-10-27 08:50 by Ronny.Pfannschmidt , last changed 2022-04-11 14:57 by admin . This issue is now closed .
Messages (6)
msg146483 - (view)
Author: Ronny Pfannschmidt (Ronny.Pfannschmidt)
Date: 2011-10-27 08:50
the problem manifests when calling with negative counts when the c versions are used, a empty list is returned, however if the pure python version is called islice errors out
msg146531 - (view)
Author: Raymond Hettinger (rhettinger) *
Date: 2011-10-28 03:09
The behavior is undefined for negative inputs, so implementations are free to the most expedient choices.
msg146621 - (view)
Author: Ronny Pfannschmidt (Ronny.Pfannschmidt)
Date: 2011-10-29 20:43
however some basic consistency between the cpython and pure python versions within the stdlib would be nice since it basically implicitly breaks unaware code on non cpython
msg146659 - (view)
Author: Roundup Robot (python-dev)
Date: 2011-10-30 21:29
New changeset 57f73b0f921c by Raymond Hettinger in branch '2.7': Issue 13274 : Make the pure python code for heapq more closely match the C implementation for an undefined corner case. http://hg.python.org/cpython/rev/57f73b0f921c
msg146660 - (view)
Author: Roundup Robot (python-dev)
Date: 2011-10-30 21:33
New changeset 155e57a449b5 by Raymond Hettinger in branch '3.2': Issue 13274 : Make the pure python code for heapq more closely match the C implementation for an undefined corner case. http://hg.python.org/cpython/rev/155e57a449b5
msg146661 - (view)
Author: Raymond Hettinger (rhettinger) *
Date: 2011-10-30 21:38
I went ahead an added the guards to the pure python code. Still disagree with your assertion that non-cpython implementations were somehow broken when an undefined behavior was implemented in a different way -- nsmallest() and nlargest() have no guaranteed meaning for negative numbers.
History
Date
User
Action
Args
2022-04-11 14:57:23
admin
set
github: 57483
2011-10-30 21:38:15
rhettinger
set
messages: +
2011-10-30 21:33:59
python-dev
set
messages: +
2011-10-30 21:29:23
python-dev
set
nosy: + python-dev messages: +
2011-10-30 02:47:44
rhettinger
set
status: open -> closedresolution: not a bug
2011-10-30 01:08:38
alex
set
nosy: + alex
2011-10-29 20:43:13
Ronny.Pfannschmidt
set
messages: +
2011-10-28 03:09:06
rhettinger
set
priority: normal -> lowmessages: +
2011-10-27 15:39:09
eric.araujo
set
stage: test neededversions: - Python 2.6, Python 3.1, Python 3.4
2011-10-27 12:54:42
benjamin.peterson
set
nosy: + rhettinger
2011-10-27 12:28:47
petri.lehtinen
set
nosy: + petri.lehtinen
2011-10-27 08:50:24
Ronny.Pfannschmidt
create