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
fc6e8fe5
Kaydet (Commit)
fc6e8fe5
authored
Ock 11, 2008
tarafından
Eric Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Simplifed argument parsing in object.__format__, added test case.
üst
0041223f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
test_builtin.py
Lib/test/test_builtin.py
+4
-0
typeobject.c
Objects/typeobject.c
+1
-5
No files found.
Lib/test/test_builtin.py
Dosyayı görüntüle @
fc6e8fe5
...
@@ -558,6 +558,10 @@ class BuiltinTest(unittest.TestCase):
...
@@ -558,6 +558,10 @@ class BuiltinTest(unittest.TestCase):
# TypeError because self.__format__ returns the wrong type
# TypeError because self.__format__ returns the wrong type
self
.
assertRaises
(
TypeError
,
format
,
B
(),
""
)
self
.
assertRaises
(
TypeError
,
format
,
B
(),
""
)
# TypeError because format_spec is not unicode
self
.
assertRaises
(
TypeError
,
format
,
object
(),
4
)
self
.
assertRaises
(
TypeError
,
format
,
object
(),
object
())
# make sure we can take a subclass of str as a format spec
# make sure we can take a subclass of str as a format spec
self
.
assertEqual
(
format
(
0
,
C
(
'10'
)),
' 0'
)
self
.
assertEqual
(
format
(
0
,
C
(
'10'
)),
' 0'
)
...
...
Objects/typeobject.c
Dosyayı görüntüle @
fc6e8fe5
...
@@ -2950,12 +2950,8 @@ object_format(PyObject *self, PyObject *args)
...
@@ -2950,12 +2950,8 @@ object_format(PyObject *self, PyObject *args)
PyObject
*
result
=
NULL
;
PyObject
*
result
=
NULL
;
PyObject
*
format_meth
=
NULL
;
PyObject
*
format_meth
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"
O
:__format__"
,
&
format_spec
))
if
(
!
PyArg_ParseTuple
(
args
,
"
U
:__format__"
,
&
format_spec
))
return
NULL
;
return
NULL
;
if
(
!
PyUnicode_Check
(
format_spec
))
{
PyErr_SetString
(
PyExc_TypeError
,
"Unicode object required"
);
return
NULL
;
}
self_as_str
=
PyObject_Str
(
self
);
self_as_str
=
PyObject_Str
(
self
);
if
(
self_as_str
!=
NULL
)
{
if
(
self_as_str
!=
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