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
33e4a98a
Kaydet (Commit)
33e4a98a
authored
May 07, 2008
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Replace more float hacks with correct math functions
üst
342c095b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
encoder.py
Lib/json/encoder.py
+7
-7
No files found.
Lib/json/encoder.py
Dosyayı görüntüle @
33e4a98a
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
"""
"""
import
re
import
re
import
math
try
:
try
:
from
_json
import
encode_basestring_ascii
as
c_encode_basestring_ascii
from
_json
import
encode_basestring_ascii
as
c_encode_basestring_ascii
...
@@ -25,20 +26,19 @@ ESCAPE_DCT = {
...
@@ -25,20 +26,19 @@ ESCAPE_DCT = {
for
i
in
range
(
0x20
):
for
i
in
range
(
0x20
):
ESCAPE_DCT
.
setdefault
(
chr
(
i
),
'
\\
u{0:04x}'
.
format
(
i
))
ESCAPE_DCT
.
setdefault
(
chr
(
i
),
'
\\
u{0:04x}'
.
format
(
i
))
# Assume this produces an infinity on all machines (probably not guaranteed)
INFINITY
=
float
(
'1e66666'
)
FLOAT_REPR
=
repr
FLOAT_REPR
=
repr
def
floatstr
(
o
,
allow_nan
=
True
):
def
floatstr
(
o
,
allow_nan
=
True
):
# Check for specials. Note that this type of test is processor- and/or
# Check for specials. Note that this type of test is processor- and/or
# platform-specific, so do tests which don't depend on the internals.
# platform-specific, so do tests which don't depend on the internals.
if
o
!=
o
:
if
math
.
isnan
(
o
)
:
text
=
'NaN'
text
=
'NaN'
elif
o
==
INFINITY
:
elif
math
.
isinf
(
o
):
text
=
'Infinity'
if
math
.
copysign
(
1.
,
o
)
==
1.
:
elif
o
==
-
INFINITY
:
text
=
'Infinity'
text
=
'-Infinity'
else
:
text
=
'-Infinity'
else
:
else
:
return
FLOAT_REPR
(
o
)
return
FLOAT_REPR
(
o
)
...
...
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