Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
46f5ca31
Kaydet (Commit)
46f5ca31
authored
Eyl 15, 2013
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19018: The heapq.merge() function no longer suppresses IndexError
üst
0a32d92b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
5 deletions
+23
-5
heapq.py
Lib/heapq.py
+9
-5
test_heapq.py
Lib/test/test_heapq.py
+9
-0
ACKS
Misc/ACKS
+2
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/heapq.py
Dosyayı görüntüle @
46f5ca31
...
...
@@ -358,6 +358,7 @@ def merge(*iterables):
'''
_heappop
,
_heapreplace
,
_StopIteration
=
heappop
,
heapreplace
,
StopIteration
_len
=
len
h
=
[]
h_append
=
h
.
append
...
...
@@ -369,17 +370,20 @@ def merge(*iterables):
pass
heapify
(
h
)
while
1
:
while
_len
(
h
)
>
1
:
try
:
while
1
:
v
,
itnum
,
next
=
s
=
h
[
0
]
# raises IndexError when h is empty
while
True
:
v
,
itnum
,
next
=
s
=
h
[
0
]
yield
v
s
[
0
]
=
next
()
# raises StopIteration when exhausted
_heapreplace
(
h
,
s
)
# restore heap condition
except
_StopIteration
:
_heappop
(
h
)
# remove empty iterator
except
IndexError
:
return
if
h
:
# fast case when only a single iterator remains
v
,
itnum
,
next
=
h
[
0
]
yield
v
yield
from
next
.
__self__
# Extend the implementations of nsmallest and nlargest to use a key= argument
_nsmallest
=
nsmallest
...
...
Lib/test/test_heapq.py
Dosyayı görüntüle @
46f5ca31
...
...
@@ -158,6 +158,15 @@ class TestHeap:
self
.
assertEqual
(
sorted
(
chain
(
*
inputs
)),
list
(
self
.
module
.
merge
(
*
inputs
)))
self
.
assertEqual
(
list
(
self
.
module
.
merge
()),
[])
def
test_merge_does_not_suppress_index_error
(
self
):
# Issue 19018: Heapq.merge suppresses IndexError from user generator
def
iterable
():
s
=
list
(
range
(
10
))
for
i
in
range
(
20
):
yield
s
[
i
]
# IndexError when i > 10
with
self
.
assertRaises
(
IndexError
):
list
(
self
.
module
.
merge
(
iterable
(),
iterable
()))
def
test_merge_stability
(
self
):
class
Int
(
int
):
pass
...
...
Misc/ACKS
Dosyayı görüntüle @
46f5ca31
...
...
@@ -133,6 +133,7 @@ Paul Boddie
Matthew Boedicker
Robin Boerdijk
David Bolen
Wouter Bolsterlee
Gawain Bolton
Forest Bond
Gregory Bond
...
...
@@ -382,6 +383,7 @@ Nils Fischbeck
Frederik Fix
Matt Fleming
Hernán Martínez Foffani
Artem Fokin
Arnaud Fontaine
Michael Foord
Amaury Forgeot d'Arc
...
...
Misc/NEWS
Dosyayı görüntüle @
46f5ca31
...
...
@@ -72,6 +72,9 @@ Library
- Issue #17324: Fix http.server'
s
request
handling
case
on
trailing
'/'
.
Patch
contributed
by
Vajrasky
Kok
.
-
Issue
#
19018
:
The
heapq
.
merge
()
function
no
longer
suppresses
IndexError
in
the
underlying
iterables
.
-
Issue
#
18784
:
The
uuid
module
no
more
attempts
to
load
libc
via
ctypes
.
CDLL
,
if
all
necessary
functions
are
already
found
in
libuuid
.
Patch
by
Evgeny
Sologubov
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment