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
f9724882
Kaydet (Commit)
f9724882
authored
Eki 26, 2009
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove length limitation on string arguments to complex()
üst
f0966c95
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
test_complex.py
Lib/test/test_complex.py
+3
-1
NEWS
Misc/NEWS
+2
-0
complexobject.c
Objects/complexobject.c
+11
-7
No files found.
Lib/test/test_complex.py
Dosyayı görüntüle @
f9724882
...
...
@@ -284,7 +284,6 @@ class ComplexTest(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
complex
,
"1+2j)"
)
self
.
assertRaises
(
ValueError
,
complex
,
"1+(2j)"
)
self
.
assertRaises
(
ValueError
,
complex
,
"(1+2j)123"
)
self
.
assertRaises
(
ValueError
,
complex
,
"1"
*
500
)
self
.
assertRaises
(
ValueError
,
complex
,
"x"
)
self
.
assertRaises
(
ValueError
,
complex
,
"1j+2"
)
self
.
assertRaises
(
ValueError
,
complex
,
"1e1ej"
)
...
...
@@ -295,6 +294,9 @@ class ComplexTest(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
complex
,
"1.11.1j"
)
self
.
assertRaises
(
ValueError
,
complex
,
"1e1.1j"
)
# check that complex accepts long unicode strings
self
.
assertEqual
(
type
(
complex
(
"1"
*
500
)),
complex
)
class
EvilExc
(
Exception
):
pass
...
...
Misc/NEWS
Dosyayı görüntüle @
f9724882
...
...
@@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 1?
Core and Builtins
-----------------
- Remove length limitation when constructing a complex number from a string.
- Issue #1087418: Boost performance of bitwise operations for longs.
- Support for AtheOS has been completely removed from the code base. It was
...
...
Objects/complexobject.c
Dosyayı görüntüle @
f9724882
...
...
@@ -740,20 +740,20 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
char
*
end
;
double
x
=
0
.
0
,
y
=
0
.
0
,
z
;
int
got_bracket
=
0
;
char
s_buffer
[
256
]
;
char
*
s_buffer
=
NULL
;
Py_ssize_t
len
;
if
(
PyUnicode_Check
(
v
))
{
if
(
PyUnicode_GET_SIZE
(
v
)
>=
(
Py_ssize_t
)
sizeof
(
s_buffer
))
{
PyErr_SetString
(
PyExc_ValueError
,
"complex() literal too large to convert"
);
return
NULL
;
}
s_buffer
=
(
char
*
)
PyMem_MALLOC
(
PyUnicode_GET_SIZE
(
v
)
+
1
);
if
(
s_buffer
==
NULL
)
return
PyErr_NoMemory
();
if
(
PyUnicode_EncodeDecimal
(
PyUnicode_AS_UNICODE
(
v
),
PyUnicode_GET_SIZE
(
v
),
s_buffer
,
NULL
))
NULL
))
{
PyMem_FREE
(
s_buffer
);
return
NULL
;
}
s
=
s_buffer
;
len
=
strlen
(
s
);
}
...
...
@@ -870,9 +870,13 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
if
(
s
-
start
!=
len
)
goto
parse_error
;
if
(
s_buffer
)
PyMem_FREE
(
s_buffer
);
return
complex_subtype_from_doubles
(
type
,
x
,
y
);
parse_error:
if
(
s_buffer
)
PyMem_FREE
(
s_buffer
);
PyErr_SetString
(
PyExc_ValueError
,
"complex() arg is a malformed string"
);
return
NULL
;
...
...
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