Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
A
astor
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
astor
Commits
26225057
Kaydet (Commit)
26225057
authored
Mar 30, 2019
tarafından
Kodi Arfer
Kaydeden (comit)
Berker Peksag
Mar 30, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix code generation with very large integers (#130)
Fixes #127
üst
ea0dec38
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
6 deletions
+22
-6
code_gen.py
astor/code_gen.py
+11
-6
changelog.rst
docs/changelog.rst
+6
-0
test_code_gen.py
tests/test_code_gen.py
+5
-0
No files found.
astor/code_gen.py
Dosyayı görüntüle @
26225057
...
...
@@ -639,12 +639,17 @@ class SourceGenerator(ExplicitNodeVisitor):
def
part
(
p
,
imaginary
):
# Represent infinity as 1e1000 and NaN as 1e1000-1e1000.
s
=
'j'
if
imaginary
else
''
if
math
.
isinf
(
p
):
if
p
<
0
:
return
'-1e1000'
+
s
return
'1e1000'
+
s
if
math
.
isnan
(
p
):
return
'(1e1000
%
s-1e1000
%
s)'
%
(
s
,
s
)
try
:
if
math
.
isinf
(
p
):
if
p
<
0
:
return
'-1e1000'
+
s
return
'1e1000'
+
s
if
math
.
isnan
(
p
):
return
'(1e1000
%
s-1e1000
%
s)'
%
(
s
,
s
)
except
OverflowError
:
# math.isinf will raise this when given an integer
# that's too large to convert to a float.
pass
return
repr
(
p
)
+
s
real
=
part
(
x
.
real
if
isinstance
(
x
,
complex
)
else
x
,
imaginary
=
False
)
...
...
docs/changelog.rst
Dosyayı görüntüle @
26225057
...
...
@@ -35,6 +35,12 @@ Bug fixes
.. _`PR 133`: https://github.com/berkerpeksag/astor/pull/133
* Fixed code generation with very large integers.
(Reported by Adam Kucz in `Issue 127`_ and fixed by Kodi Arfer in `PR 130`_.)
.. _`Issue 127`: https://github.com/berkerpeksag/astor/issues/127
.. _`PR 130`: https://github.com/berkerpeksag/astor/pull/130
0.7.1 - 2018-07-06
------------------
...
...
tests/test_code_gen.py
Dosyayı görüntüle @
26225057
...
...
@@ -266,6 +266,11 @@ class CodegenTestCase(unittest.TestCase, Comparisons):
"""
self
.
assertAstRoundtripsGtVer
(
source
,
(
2
,
7
))
def
test_huge_int
(
self
):
for
n
in
(
10
**
10000
,
0xdfa21cd2a530ccc8c870aa60d9feb3b35deeab81c3215a96557abbd683d21f4600f38e475d87100da9a4404220eeb3bb5584e5a2b5b48ffda58530ea19104a32577d7459d91e76aa711b241050f4cc6d5327ccee254f371bcad3be56d46eb5919b73f20dbdb1177b700f00891c5bf4ed128bb90ed541b778288285bcfa28432ab5cbcb8321b6e24760e998e0daa519f093a631e44276d7dd252ce0c08c75e2ab28a7349ead779f97d0f20a6d413bf3623cd216dc35375f6366690bcc41e3b2d5465840ec7ee0dc7e3f1c101d674a0c7dbccbc3942788b111396add2f8153b46a0e4b50d66e57ee92958f1c860dd97cc0e40e32febff915343ed53573142bdf4b
):
self
.
assertEqual
(
astornum
(
n
),
n
)
def
test_complex
(
self
):
source
=
"""
(3) + (4j) + (1+2j) + (1+0j)
...
...
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