summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorMichael <216956+mikez@users.noreply.github.com>2022-10-03 22:28:02 (GMT)
committerGitHub <noreply@github.com>2022-10-03 22:28:02 (GMT)
commit07b8e85d0e29bc59a7a7d7d662db500c93980edb (patch)
treed833d08cdd4c706ddc5c5ecb02d4129c6294636a /Python/bltinmodule.c
parent0ea8b925d096629852d1045c2c53ff6ad63199cc (diff)
downloadcpython-07b8e85d0e29bc59a7a7d7d662db500c93980edb.zip
cpython-07b8e85d0e29bc59a7a7d7d662db500c93980edb.tar.gz
cpython-07b8e85d0e29bc59a7a7d7d662db500c93980edb.tar.bz2
gh-96526: Clarify format and __format__ docstrings (gh-96648)
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 551e4f3..2809b03 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -677,16 +677,19 @@ format as builtin_format
format_spec: unicode(c_default="NULL") = ''
/
-Return value.__format__(format_spec)
+Return type(value).__format__(value, format_spec)
-format_spec defaults to the empty string.
-See the Format Specification Mini-Language section of help('FORMATTING') for
-details.
+Many built-in types implement format_spec according to the
+Format Specification Mini-language. See help('FORMATTING').
+
+If type(value) does not supply a method named __format__
+and format_spec is empty, then str(value) is returned.
+See also help('SPECIALMETHODS').
[clinic start generated code]*/
static PyObject *
builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec)
-/*[clinic end generated code: output=2f40bdfa4954b077 input=88339c93ea522b33]*/
+/*[clinic end generated code: output=2f40bdfa4954b077 input=45ef3934b86d5624]*/
{
return PyObject_Format(value, format_spec);
}