summaryrefslogtreecommitdiffstats
path: root/Objects
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 /Objects
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 'Objects')
-rw-r--r--Objects/clinic/longobject.c.h5
-rw-r--r--Objects/clinic/typeobject.c.h6
-rw-r--r--Objects/longobject.c4
-rw-r--r--Objects/typeobject.c4
4 files changed, 13 insertions, 6 deletions
diff --git a/Objects/clinic/longobject.c.h b/Objects/clinic/longobject.c.h
index 1cf5b43..dde4909 100644
--- a/Objects/clinic/longobject.c.h
+++ b/Objects/clinic/longobject.c.h
@@ -88,7 +88,8 @@ int___getnewargs__(PyObject *self, PyObject *Py_UNUSED(ignored))
PyDoc_STRVAR(int___format____doc__,
"__format__($self, format_spec, /)\n"
"--\n"
-"\n");
+"\n"
+"Convert to a string according to format_spec.");
#define INT___FORMAT___METHODDEF \
{"__format__", (PyCFunction)int___format__, METH_O, int___format____doc__},
@@ -466,4 +467,4 @@ skip_optional_kwonly:
exit:
return return_value;
}
-/*[clinic end generated code: output=b29b4afc65e3290e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=bf6074ecf2f32cf4 input=a9049054013a1b77]*/
diff --git a/Objects/clinic/typeobject.c.h b/Objects/clinic/typeobject.c.h
index f286429..dc9746a 100644
--- a/Objects/clinic/typeobject.c.h
+++ b/Objects/clinic/typeobject.c.h
@@ -204,7 +204,9 @@ PyDoc_STRVAR(object___format____doc__,
"__format__($self, format_spec, /)\n"
"--\n"
"\n"
-"Default object formatter.");
+"Default object formatter.\n"
+"\n"
+"Return str(self) if format_spec is empty. Raise TypeError otherwise.");
#define OBJECT___FORMAT___METHODDEF \
{"__format__", (PyCFunction)object___format__, METH_O, object___format____doc__},
@@ -267,4 +269,4 @@ object___dir__(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return object___dir___impl(self);
}
-/*[clinic end generated code: output=3312f873c970bfd1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d2fc52440a89f2fa input=a9049054013a1b77]*/
diff --git a/Objects/longobject.c b/Objects/longobject.c
index d9f3d39..8b13df4 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -5528,11 +5528,13 @@ int.__format__
format_spec: unicode
/
+
+Convert to a string according to format_spec.
[clinic start generated code]*/
static PyObject *
int___format___impl(PyObject *self, PyObject *format_spec)
-/*[clinic end generated code: output=b4929dee9ae18689 input=e31944a9b3e428b7]*/
+/*[clinic end generated code: output=b4929dee9ae18689 input=d5e1254a47e8d1dc]*/
{
_PyUnicodeWriter writer;
int ret;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 5aa5cbb..196a6ae 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5824,11 +5824,13 @@ object.__format__
/
Default object formatter.
+
+Return str(self) if format_spec is empty. Raise TypeError otherwise.
[clinic start generated code]*/
static PyObject *
object___format___impl(PyObject *self, PyObject *format_spec)
-/*[clinic end generated code: output=34897efb543a974b input=7c3b3bc53a6fb7fa]*/
+/*[clinic end generated code: output=34897efb543a974b input=b94d8feb006689ea]*/
{
/* Issue 7994: If we're converting to a string, we
should reject format specifications */