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
dd5417af
Kaydet (Commit)
dd5417af
authored
Mar 25, 2019
tarafından
Rémi Lapeyre
Kaydeden (comit)
Raymond Hettinger
Mar 25, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-36218: Fix handling of heterogeneous values in list.sort (GH-12209)
üst
9dcc095f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
11 deletions
+30
-11
test_sort.py
Lib/test/test_sort.py
+5
-0
2019-03-07-13-05-43.bpo-36218.dZemNt.rst
...ore and Builtins/2019-03-07-13-05-43.bpo-36218.dZemNt.rst
+3
-0
listobject.c
Objects/listobject.c
+22
-11
No files found.
Lib/test/test_sort.py
Dosyayı görüntüle @
dd5417af
...
...
@@ -373,6 +373,11 @@ class TestOptimizedCompares(unittest.TestCase):
check_against_PyObject_RichCompareBool
(
self
,
[
float
(
'nan'
)]
*
100
)
check_against_PyObject_RichCompareBool
(
self
,
[
float
(
'nan'
)
for
_
in
range
(
100
)])
def
test_not_all_tuples
(
self
):
self
.
assertRaises
(
TypeError
,
[(
1.0
,
1.0
),
(
False
,
"A"
),
6
]
.
sort
)
self
.
assertRaises
(
TypeError
,
[(
'a'
,
1
),
(
1
,
'a'
)]
.
sort
)
self
.
assertRaises
(
TypeError
,
[(
1
,
'a'
),
(
'a'
,
1
)]
.
sort
)
#==============================================================================
if
__name__
==
"__main__"
:
...
...
Misc/NEWS.d/next/Core and Builtins/2019-03-07-13-05-43.bpo-36218.dZemNt.rst
0 → 100644
Dosyayı görüntüle @
dd5417af
Fix a segfault occuring when sorting a list of heterogeneous values. Patch
contributed by Rémi Lapeyre and Elliot Gorokhovsky.
\ No newline at end of file
Objects/listobject.c
Dosyayı görüntüle @
dd5417af
...
...
@@ -2306,19 +2306,28 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
if
(
key
->
ob_type
!=
key_type
)
{
keys_are_all_same_type
=
0
;
break
;
/* If keys are in tuple we must loop over the whole list to make
sure all items are tuples */
if
(
!
keys_are_in_tuples
)
{
break
;
}
}
if
(
key_type
==
&
PyLong_Type
)
{
if
(
ints_are_bounded
&&
Py_ABS
(
Py_SIZE
(
key
))
>
1
)
if
(
keys_are_all_same_type
)
{
if
(
key_type
==
&
PyLong_Type
&&
ints_are_bounded
&&
Py_ABS
(
Py_SIZE
(
key
))
>
1
)
{
ints_are_bounded
=
0
;
}
else
if
(
key_type
==
&
PyUnicode_Type
&&
strings_are_latin
&&
PyUnicode_KIND
(
key
)
!=
PyUnicode_1BYTE_KIND
)
{
strings_are_latin
=
0
;
}
}
}
else
if
(
key_type
==
&
PyUnicode_Type
){
if
(
strings_are_latin
&&
PyUnicode_KIND
(
key
)
!=
PyUnicode_1BYTE_KIND
)
strings_are_latin
=
0
;
}
}
/* Choose the best compare, given what we now know about the keys. */
if
(
keys_are_all_same_type
)
{
...
...
@@ -2346,10 +2355,12 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
if
(
keys_are_in_tuples
)
{
/* Make sure we're not dealing with tuples of tuples
* (remember: here, key_type refers list [key[0] for key in keys]) */
if
(
key_type
==
&
PyTuple_Type
)
if
(
key_type
==
&
PyTuple_Type
)
{
ms
.
tuple_elem_compare
=
safe_object_compare
;
else
}
else
{
ms
.
tuple_elem_compare
=
ms
.
key_compare
;
}
ms
.
key_compare
=
unsafe_tuple_compare
;
}
...
...
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