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
94b7d3db
Kaydet (Commit)
94b7d3db
authored
Ara 11, 2007
tarafından
Christian Heimes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #1593 spacing of the builtin_format function is inconsistent. Thanks to Joseph for the fix
üst
a3534a6f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
50 deletions
+50
-50
bltinmodule.c
Python/bltinmodule.c
+50
-50
No files found.
Python/bltinmodule.c
Dosyayı görüntüle @
94b7d3db
...
...
@@ -284,58 +284,58 @@ If the predicate is None, 'lambda x: bool(x)' is assumed.\n\
static
PyObject
*
builtin_format
(
PyObject
*
self
,
PyObject
*
args
)
{
static
PyObject
*
format_str
=
NULL
;
PyObject
*
value
;
PyObject
*
spec
=
NULL
;
PyObject
*
meth
;
PyObject
*
empty
=
NULL
;
PyObject
*
result
=
NULL
;
/* Initialize cached value */
if
(
format_str
==
NULL
)
{
/* Initialize static variable needed by _PyType_Lookup */
format_str
=
PyUnicode_FromString
(
"__format__"
);
if
(
format_str
==
NULL
)
goto
done
;
}
if
(
!
PyArg_ParseTuple
(
args
,
"O|U:format"
,
&
value
,
&
spec
))
goto
done
;
/* initialize the default value */
if
(
spec
==
NULL
)
{
empty
=
PyUnicode_FromUnicode
(
NULL
,
0
);
spec
=
empty
;
}
/* Make sure the type is initialized. float gets initialized late */
if
(
Py_Type
(
value
)
->
tp_dict
==
NULL
)
if
(
PyType_Ready
(
Py_Type
(
value
))
<
0
)
goto
done
;
/* Find the (unbound!) __format__ method (a borrowed reference) */
meth
=
_PyType_Lookup
(
Py_Type
(
value
),
format_str
);
if
(
meth
==
NULL
)
{
PyErr_Format
(
PyExc_TypeError
,
"Type %.100s doesn't define __format__"
,
Py_Type
(
value
)
->
tp_name
);
goto
done
;
}
/* And call it, binding it to the value */
result
=
PyObject_CallFunctionObjArgs
(
meth
,
value
,
spec
,
NULL
);
if
(
result
&&
!
PyUnicode_Check
(
result
))
{
PyErr_SetString
(
PyExc_TypeError
,
"__format__ method did not return string"
);
Py_DECREF
(
result
);
result
=
NULL
;
goto
done
;
}
static
PyObject
*
format_str
=
NULL
;
PyObject
*
value
;
PyObject
*
spec
=
NULL
;
PyObject
*
meth
;
PyObject
*
empty
=
NULL
;
PyObject
*
result
=
NULL
;
/* Initialize cached value */
if
(
format_str
==
NULL
)
{
/* Initialize static variable needed by _PyType_Lookup */
format_str
=
PyUnicode_FromString
(
"__format__"
);
if
(
format_str
==
NULL
)
goto
done
;
}
if
(
!
PyArg_ParseTuple
(
args
,
"O|U:format"
,
&
value
,
&
spec
))
goto
done
;
/* initialize the default value */
if
(
spec
==
NULL
)
{
empty
=
PyUnicode_FromUnicode
(
NULL
,
0
);
spec
=
empty
;
}
/* Make sure the type is initialized. float gets initialized late */
if
(
Py_Type
(
value
)
->
tp_dict
==
NULL
)
if
(
PyType_Ready
(
Py_Type
(
value
))
<
0
)
goto
done
;
/* Find the (unbound!) __format__ method (a borrowed reference) */
meth
=
_PyType_Lookup
(
Py_Type
(
value
),
format_str
);
if
(
meth
==
NULL
)
{
PyErr_Format
(
PyExc_TypeError
,
"Type %.100s doesn't define __format__"
,
Py_Type
(
value
)
->
tp_name
);
goto
done
;
}
/* And call it, binding it to the value */
result
=
PyObject_CallFunctionObjArgs
(
meth
,
value
,
spec
,
NULL
);
if
(
result
&&
!
PyUnicode_Check
(
result
))
{
PyErr_SetString
(
PyExc_TypeError
,
"__format__ method did not return string"
);
Py_DECREF
(
result
);
result
=
NULL
;
goto
done
;
}
done:
Py_XDECREF
(
empty
);
return
result
;
Py_XDECREF
(
empty
);
return
result
;
}
PyDoc_STRVAR
(
format_doc
,
...
...
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