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
85c0b894
Kaydet (Commit)
85c0b894
authored
7 years ago
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
7 years ago
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31619: Fixed a ValueError when convert a string with large number of underscores (#3827)
to integer with binary base.
üst
1a87de7f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
test_int.py
Lib/test/test_int.py
+8
-0
2017-09-29-20-32-24.bpo-31619.6gQ1kv.rst
...ore and Builtins/2017-09-29-20-32-24.bpo-31619.6gQ1kv.rst
+2
-0
longobject.c
Objects/longobject.c
+4
-4
No files found.
Lib/test/test_int.py
Dosyayı görüntüle @
85c0b894
...
...
@@ -508,5 +508,13 @@ class IntTestCases(unittest.TestCase):
check
(
'123
\ud800
'
)
check
(
'123
\ud800
'
,
10
)
def
test_issue31619
(
self
):
self
.
assertEqual
(
int
(
'1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1'
,
2
),
0
b1010101010101010101010101010101
)
self
.
assertEqual
(
int
(
'1_2_3_4_5_6_7_0_1_2_3'
,
8
),
0
o12345670123
)
self
.
assertEqual
(
int
(
'1_2_3_4_5_6_7_8_9'
,
16
),
0x123456789
)
self
.
assertEqual
(
int
(
'1_2_3_4_5_6_7'
,
32
),
1144132807
)
if
__name__
==
"__main__"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Misc/NEWS.d/next/Core and Builtins/2017-09-29-20-32-24.bpo-31619.6gQ1kv.rst
0 → 100644
Dosyayı görüntüle @
85c0b894
Fixed a ValueError when convert a string with large number of underscores
to integer with binary base.
This diff is collapsed.
Click to expand it.
Objects/longobject.c
Dosyayı görüntüle @
85c0b894
...
...
@@ -2057,15 +2057,15 @@ long_from_binary_base(const char **str, int base, PyLongObject **res)
}
*
str
=
p
;
/* n <-
# of Python digits needed, = ceiling(n/PyLong_SHIFT). */
n
=
digits
*
bits_per_char
+
PyLong_SHIFT
-
1
;
if
(
n
/
bits_per_char
<
p
-
start
)
{
/* n <-
the number of Python digits needed,
= ceiling((digits * bits_per_char) / PyLong_SHIFT). */
if
(
digits
>
(
PY_SSIZE_T_MAX
-
(
PyLong_SHIFT
-
1
))
/
bits_per_char
)
{
PyErr_SetString
(
PyExc_ValueError
,
"int string too large to convert"
);
*
res
=
NULL
;
return
0
;
}
n
=
n
/
PyLong_SHIFT
;
n
=
(
digits
*
bits_per_char
+
PyLong_SHIFT
-
1
)
/
PyLong_SHIFT
;
z
=
_PyLong_New
(
n
);
if
(
z
==
NULL
)
{
*
res
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
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