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
2336bddd
Kaydet (Commit)
2336bddd
authored
Ock 19, 2008
tarafından
Facundo Batista
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue #1769: Now int('- 1') or int('+ 1') is not allowed
any more. Thanks Juan Jose Conti. Also added tests.
üst
587c2bfe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
5 deletions
+37
-5
test_builtin.py
Lib/test/test_builtin.py
+35
-3
NEWS
Misc/NEWS
+2
-0
longobject.c
Objects/longobject.c
+0
-2
No files found.
Lib/test/test_builtin.py
Dosyayı görüntüle @
2336bddd
...
@@ -49,7 +49,7 @@ class BitBucket:
...
@@ -49,7 +49,7 @@ class BitBucket:
def
write
(
self
,
line
):
def
write
(
self
,
line
):
pass
pass
L
=
[
test_conv_no_sign
=
[
(
'0'
,
0
),
(
'0'
,
0
),
(
'1'
,
1
),
(
'1'
,
1
),
(
'9'
,
9
),
(
'9'
,
9
),
...
@@ -71,6 +71,28 @@ L = [
...
@@ -71,6 +71,28 @@ L = [
(
chr
(
0x200
),
ValueError
),
(
chr
(
0x200
),
ValueError
),
]
]
test_conv_sign
=
[
(
'0'
,
0
),
(
'1'
,
1
),
(
'9'
,
9
),
(
'10'
,
10
),
(
'99'
,
99
),
(
'100'
,
100
),
(
'314'
,
314
),
(
' 314'
,
ValueError
),
(
'314 '
,
314
),
(
'
\t\t
314
\t\t
'
,
ValueError
),
(
repr
(
sys
.
maxsize
),
sys
.
maxsize
),
(
' 1x'
,
ValueError
),
(
' 1 '
,
ValueError
),
(
' 1
\02
'
,
ValueError
),
(
''
,
ValueError
),
(
' '
,
ValueError
),
(
'
\t\t
'
,
ValueError
),
(
str
(
b
'
\u0663\u0661\u0664
'
,
'raw-unicode-escape'
),
314
),
(
chr
(
0x200
),
ValueError
),
]
class
TestFailingBool
:
class
TestFailingBool
:
def
__bool__
(
self
):
def
__bool__
(
self
):
raise
RuntimeError
raise
RuntimeError
...
@@ -641,8 +663,18 @@ class BuiltinTest(unittest.TestCase):
...
@@ -641,8 +663,18 @@ class BuiltinTest(unittest.TestCase):
# Different base:
# Different base:
self
.
assertEqual
(
int
(
"10"
,
16
),
16
)
self
.
assertEqual
(
int
(
"10"
,
16
),
16
)
# Test conversion from strings and various anomalies
# Test conversion from strings and various anomalies
for
s
,
v
in
L
:
# Testing with no sign at front
for
sign
in
""
,
"+"
,
"-"
:
for
s
,
v
in
test_conv_no_sign
:
for
prefix
in
""
,
" "
,
"
\t
"
,
"
\t\t
"
:
ss
=
prefix
+
s
vv
=
v
try
:
self
.
assertEqual
(
int
(
ss
),
vv
)
except
v
:
pass
# No whitespaces allowed between + or - sign and the number
for
s
,
v
in
test_conv_sign
:
for
sign
in
"+"
,
"-"
:
for
prefix
in
""
,
" "
,
"
\t
"
,
"
\t\t
"
:
for
prefix
in
""
,
" "
,
"
\t
"
,
"
\t\t
"
:
ss
=
prefix
+
sign
+
s
ss
=
prefix
+
sign
+
s
vv
=
v
vv
=
v
...
...
Misc/NEWS
Dosyayı görüntüle @
2336bddd
...
@@ -12,6 +12,8 @@ What's New in Python 3.0a3?
...
@@ -12,6 +12,8 @@ What's New in Python 3.0a3?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #1769: Now int("- 1") is not allowed any more.
- Object/longobject.c: long(float('nan')) raises an OverflowError instead
- Object/longobject.c: long(float('nan')) raises an OverflowError instead
of returning 0.
of returning 0.
...
...
Objects/longobject.c
Dosyayı görüntüle @
2336bddd
...
@@ -1685,8 +1685,6 @@ PyLong_FromString(char *str, char **pend, int base)
...
@@ -1685,8 +1685,6 @@ PyLong_FromString(char *str, char **pend, int base)
++
str
;
++
str
;
sign
=
-
1
;
sign
=
-
1
;
}
}
while
(
*
str
!=
'\0'
&&
isspace
(
Py_CHARMASK
(
*
str
)))
str
++
;
if
(
base
==
0
)
{
if
(
base
==
0
)
{
if
(
str
[
0
]
!=
'0'
)
if
(
str
[
0
]
!=
'0'
)
base
=
10
;
base
=
10
;
...
...
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