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
Hide 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):
...
@@ -358,6 +358,7 @@ def merge(*iterables):
'''
'''
_heappop
,
_heapreplace
,
_StopIteration
=
heappop
,
heapreplace
,
StopIteration
_heappop
,
_heapreplace
,
_StopIteration
=
heappop
,
heapreplace
,
StopIteration
_len
=
len
h
=
[]
h
=
[]
h_append
=
h
.
append
h_append
=
h
.
append
...
@@ -369,17 +370,20 @@ def merge(*iterables):
...
@@ -369,17 +370,20 @@ def merge(*iterables):
pass
pass
heapify
(
h
)
heapify
(
h
)
while
1
:
while
_len
(
h
)
>
1
:
try
:
try
:
while
1
:
while
True
:
v
,
itnum
,
next
=
s
=
h
[
0
]
# raises IndexError when h is empty
v
,
itnum
,
next
=
s
=
h
[
0
]
yield
v
yield
v
s
[
0
]
=
next
()
# raises StopIteration when exhausted
s
[
0
]
=
next
()
# raises StopIteration when exhausted
_heapreplace
(
h
,
s
)
# restore heap condition
_heapreplace
(
h
,
s
)
# restore heap condition
except
_StopIteration
:
except
_StopIteration
:
_heappop
(
h
)
# remove empty iterator
_heappop
(
h
)
# remove empty iterator
except
IndexError
:
if
h
:
return
# 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
# Extend the implementations of nsmallest and nlargest to use a key= argument
_nsmallest
=
nsmallest
_nsmallest
=
nsmallest
...
...
Lib/test/test_heapq.py
Dosyayı görüntüle @
46f5ca31
...
@@ -158,6 +158,15 @@ class TestHeap:
...
@@ -158,6 +158,15 @@ class TestHeap:
self
.
assertEqual
(
sorted
(
chain
(
*
inputs
)),
list
(
self
.
module
.
merge
(
*
inputs
)))
self
.
assertEqual
(
sorted
(
chain
(
*
inputs
)),
list
(
self
.
module
.
merge
(
*
inputs
)))
self
.
assertEqual
(
list
(
self
.
module
.
merge
()),
[])
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
):
def
test_merge_stability
(
self
):
class
Int
(
int
):
class
Int
(
int
):
pass
pass
...
...
Misc/ACKS
Dosyayı görüntüle @
46f5ca31
...
@@ -133,6 +133,7 @@ Paul Boddie
...
@@ -133,6 +133,7 @@ Paul Boddie
Matthew Boedicker
Matthew Boedicker
Robin Boerdijk
Robin Boerdijk
David Bolen
David Bolen
Wouter Bolsterlee
Gawain Bolton
Gawain Bolton
Forest Bond
Forest Bond
Gregory Bond
Gregory Bond
...
@@ -382,6 +383,7 @@ Nils Fischbeck
...
@@ -382,6 +383,7 @@ Nils Fischbeck
Frederik Fix
Frederik Fix
Matt Fleming
Matt Fleming
Hernán Martínez Foffani
Hernán Martínez Foffani
Artem Fokin
Arnaud Fontaine
Arnaud Fontaine
Michael Foord
Michael Foord
Amaury Forgeot d'Arc
Amaury Forgeot d'Arc
...
...
Misc/NEWS
Dosyayı görüntüle @
46f5ca31
...
@@ -72,6 +72,9 @@ Library
...
@@ -72,6 +72,9 @@ Library
- Issue #17324: Fix http.server'
s
request
handling
case
on
trailing
'/'
.
Patch
- Issue #17324: Fix http.server'
s
request
handling
case
on
trailing
'/'
.
Patch
contributed
by
Vajrasky
Kok
.
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
,
-
Issue
#
18784
:
The
uuid
module
no
more
attempts
to
load
libc
via
ctypes
.
CDLL
,
if
all
necessary
functions
are
already
found
in
libuuid
.
if
all
necessary
functions
are
already
found
in
libuuid
.
Patch
by
Evgeny
Sologubov
.
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