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
604cd6ae
Kaydet (Commit)
604cd6ae
authored
Agu 29, 2002
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
complex() was the only numeric constructor that created a new instance
when given its own type as an argument.
üst
18bd1120
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
test_b1.py
Lib/test/test_b1.py
+4
-0
complexobject.c
Objects/complexobject.c
+9
-0
No files found.
Lib/test/test_b1.py
Dosyayı görüntüle @
604cd6ae
...
@@ -140,6 +140,10 @@ if complex(0.0, 3.14) != 3.14j: raise TestFailed, 'complex(0.0, 3.14)'
...
@@ -140,6 +140,10 @@ if complex(0.0, 3.14) != 3.14j: raise TestFailed, 'complex(0.0, 3.14)'
if
complex
(
"1"
)
!=
1
+
0
j
:
raise
TestFailed
,
'complex("1")'
if
complex
(
"1"
)
!=
1
+
0
j
:
raise
TestFailed
,
'complex("1")'
if
complex
(
"1j"
)
!=
1
j
:
raise
TestFailed
,
'complex("1j")'
if
complex
(
"1j"
)
!=
1
j
:
raise
TestFailed
,
'complex("1j")'
c
=
3.14
+
1
j
if
complex
(
c
)
is
not
c
:
raise
TestFailed
,
'complex(3.14+1j) changed identity'
del
c
try
:
complex
(
"1"
,
"1"
)
try
:
complex
(
"1"
,
"1"
)
except
TypeError
:
pass
except
TypeError
:
pass
else
:
raise
TestFailed
,
'complex("1", "1")'
else
:
raise
TestFailed
,
'complex("1", "1")'
...
...
Objects/complexobject.c
Dosyayı görüntüle @
604cd6ae
...
@@ -823,6 +823,15 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -823,6 +823,15 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OO:complex"
,
kwlist
,
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"|OO:complex"
,
kwlist
,
&
r
,
&
i
))
&
r
,
&
i
))
return
NULL
;
return
NULL
;
/* Special-case for single argumet that is already complex */
if
(
PyComplex_CheckExact
(
r
)
&&
i
==
NULL
)
{
/* Note that we can't know whether it's safe to return
a complex *subclass* instance as-is, hence the restriction
to exact complexes here. */
Py_INCREF
(
r
);
return
r
;
}
if
(
PyString_Check
(
r
)
||
PyUnicode_Check
(
r
))
{
if
(
PyString_Check
(
r
)
||
PyUnicode_Check
(
r
))
{
if
(
i
!=
NULL
)
{
if
(
i
!=
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
...
...
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