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
fcfff0a7
Kaydet (Commit)
fcfff0a7
authored
Tem 03, 2006
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1417699: Reject locale-specific decimal point in float()
and atof().
üst
82c276ea
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
3 deletions
+27
-3
test__locale.py
Lib/test/test__locale.py
+3
-0
test_builtin.py
Lib/test/test_builtin.py
+14
-3
NEWS
Misc/NEWS
+3
-0
pystrtod.c
Python/pystrtod.c
+7
-0
No files found.
Lib/test/test__locale.py
Dosyayı görüntüle @
fcfff0a7
...
...
@@ -113,6 +113,9 @@ class _LocaleTests(unittest.TestCase):
"using eval('3.14') failed for
%
s"
%
loc
)
self
.
assertEquals
(
int
(
float
(
'3.14'
)
*
100
),
314
,
"using float('3.14') failed for
%
s"
%
loc
)
if
localeconv
()[
'decimal_point'
]
!=
'.'
:
self
.
assertRaises
(
ValueError
,
float
,
localeconv
()[
'decimal_point'
]
.
join
([
'1'
,
'23'
]))
def
test_main
():
run_unittest
(
_LocaleTests
)
...
...
Lib/test/test_builtin.py
Dosyayı görüntüle @
fcfff0a7
...
...
@@ -558,13 +558,24 @@ class BuiltinTest(unittest.TestCase):
@run_with_locale
(
'LC_NUMERIC'
,
'fr_FR'
,
'de_DE'
)
def
test_float_with_comma
(
self
):
# set locale to something that doesn't use '.' for the decimal point
# float must not accept the locale specific decimal point but
# it still has to accept the normal python syntac
import
locale
if
not
locale
.
localeconv
()[
'decimal_point'
]
==
','
:
return
self
.
assertEqual
(
float
(
" 3,14 "
),
3.14
)
self
.
assertEqual
(
float
(
" +3,14 "
),
3.14
)
self
.
assertEqual
(
float
(
" -3,14 "
),
-
3.14
)
self
.
assertEqual
(
float
(
" 3.14 "
),
3.14
)
self
.
assertEqual
(
float
(
"+3.14 "
),
3.14
)
self
.
assertEqual
(
float
(
"-3.14 "
),
-
3.14
)
self
.
assertEqual
(
float
(
".14 "
),
.
14
)
self
.
assertEqual
(
float
(
"3. "
),
3.0
)
self
.
assertEqual
(
float
(
"3.e3 "
),
3000.0
)
self
.
assertEqual
(
float
(
"3.2e3 "
),
3200.0
)
self
.
assertEqual
(
float
(
"2.5e-1 "
),
0.25
)
self
.
assertEqual
(
float
(
"5e-1"
),
0.5
)
self
.
assertRaises
(
ValueError
,
float
,
" 3,14 "
)
self
.
assertRaises
(
ValueError
,
float
,
" +3,14 "
)
self
.
assertRaises
(
ValueError
,
float
,
" -3,14 "
)
self
.
assertRaises
(
ValueError
,
float
,
" 0x3.1 "
)
self
.
assertRaises
(
ValueError
,
float
,
" -0x3.p-1 "
)
self
.
assertEqual
(
float
(
" 25.e-1 "
),
2.5
)
...
...
Misc/NEWS
Dosyayı görüntüle @
fcfff0a7
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 beta 2?
Core and builtins
-----------------
- Bug #1417699: Reject locale-specific decimal point in float()
and atof().
- Bug #1511381: codec_getstreamcodec() in codec.c is corrected to
omit a default "error" argument for NULL pointer. This allows
the parser to take a codec from cjkcodecs again.
...
...
Python/pystrtod.c
Dosyayı görüntüle @
fcfff0a7
...
...
@@ -90,6 +90,13 @@ PyOS_ascii_strtod(const char *nptr, char **endptr)
p
++
;
end
=
p
;
}
else
if
(
strncmp
(
p
,
decimal_point
,
decimal_point_len
)
==
0
)
{
/* Python bug #1417699 */
*
endptr
=
(
char
*
)
nptr
;
errno
=
EINVAL
;
return
val
;
}
/* For the other cases, we need not convert the decimal point */
}
...
...
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