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
a5b95995
Kaydet (Commit)
a5b95995
authored
Kas 07, 2013
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#17080: improve error message of float/complex when the wrong type is passed.
üst
d0786a1a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
6 deletions
+11
-6
test_complex.py
Lib/test/test_complex.py
+1
-0
test_float.py
Lib/test/test_float.py
+1
-0
complexobject.c
Objects/complexobject.c
+6
-4
floatobject.c
Objects/floatobject.c
+3
-2
No files found.
Lib/test/test_complex.py
Dosyayı görüntüle @
a5b95995
...
@@ -303,6 +303,7 @@ class ComplexTest(unittest.TestCase):
...
@@ -303,6 +303,7 @@ class ComplexTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
float
,
5
+
3
j
)
self
.
assertRaises
(
TypeError
,
float
,
5
+
3
j
)
self
.
assertRaises
(
ValueError
,
complex
,
""
)
self
.
assertRaises
(
ValueError
,
complex
,
""
)
self
.
assertRaises
(
TypeError
,
complex
,
None
)
self
.
assertRaises
(
TypeError
,
complex
,
None
)
self
.
assertRaisesRegex
(
TypeError
,
"not 'NoneType'"
,
complex
,
None
)
self
.
assertRaises
(
ValueError
,
complex
,
"
\0
"
)
self
.
assertRaises
(
ValueError
,
complex
,
"
\0
"
)
self
.
assertRaises
(
ValueError
,
complex
,
"3
\0
9"
)
self
.
assertRaises
(
ValueError
,
complex
,
"3
\0
9"
)
self
.
assertRaises
(
TypeError
,
complex
,
"1"
,
"2"
)
self
.
assertRaises
(
TypeError
,
complex
,
"1"
,
"2"
)
...
...
Lib/test/test_float.py
Dosyayı görüntüle @
a5b95995
...
@@ -41,6 +41,7 @@ class GeneralFloatCases(unittest.TestCase):
...
@@ -41,6 +41,7 @@ class GeneralFloatCases(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
float
,
"-."
)
self
.
assertRaises
(
ValueError
,
float
,
"-."
)
self
.
assertRaises
(
ValueError
,
float
,
b
"-"
)
self
.
assertRaises
(
ValueError
,
float
,
b
"-"
)
self
.
assertRaises
(
TypeError
,
float
,
{})
self
.
assertRaises
(
TypeError
,
float
,
{})
self
.
assertRaisesRegex
(
TypeError
,
"not 'dict'"
,
float
,
{})
# Lone surrogate
# Lone surrogate
self
.
assertRaises
(
UnicodeEncodeError
,
float
,
'
\uD8F0
'
)
self
.
assertRaises
(
UnicodeEncodeError
,
float
,
'
\uD8F0
'
)
# check that we don't accept alternate exponent markers
# check that we don't accept alternate exponent markers
...
...
Objects/complexobject.c
Dosyayı görüntüle @
a5b95995
...
@@ -773,8 +773,9 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
...
@@ -773,8 +773,9 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
goto
error
;
goto
error
;
}
}
else
if
(
PyObject_AsCharBuffer
(
v
,
&
s
,
&
len
))
{
else
if
(
PyObject_AsCharBuffer
(
v
,
&
s
,
&
len
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
"complex() argument must be a string or a number"
);
"complex() argument must be a string or a number, not '%.200s'"
,
Py_TYPE
(
v
)
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
...
@@ -953,8 +954,9 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -953,8 +954,9 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
nbi
=
i
->
ob_type
->
tp_as_number
;
nbi
=
i
->
ob_type
->
tp_as_number
;
if
(
nbr
==
NULL
||
nbr
->
nb_float
==
NULL
||
if
(
nbr
==
NULL
||
nbr
->
nb_float
==
NULL
||
((
i
!=
NULL
)
&&
(
nbi
==
NULL
||
nbi
->
nb_float
==
NULL
)))
{
((
i
!=
NULL
)
&&
(
nbi
==
NULL
||
nbi
->
nb_float
==
NULL
)))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
"complex() argument must be a string or a number"
);
"complex() argument must be a string or a number, not '%.200s'"
,
Py_TYPE
(
r
)
->
tp_name
);
if
(
own_r
)
{
if
(
own_r
)
{
Py_DECREF
(
r
);
Py_DECREF
(
r
);
}
}
...
...
Objects/floatobject.c
Dosyayı görüntüle @
a5b95995
...
@@ -144,8 +144,9 @@ PyFloat_FromString(PyObject *v)
...
@@ -144,8 +144,9 @@ PyFloat_FromString(PyObject *v)
}
}
}
}
else
if
(
PyObject_AsCharBuffer
(
v
,
&
s
,
&
len
))
{
else
if
(
PyObject_AsCharBuffer
(
v
,
&
s
,
&
len
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
"float() argument must be a string or a number"
);
"float() argument must be a string or a number, not '%.200s'"
,
Py_TYPE
(
v
)
->
tp_name
);
return
NULL
;
return
NULL
;
}
}
last
=
s
+
len
;
last
=
s
+
len
;
...
...
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