[Python-checkins] gh-102595: Document `PyObject_Format` c-api function (GH-102596)

miss-islington webhook-mailer at python.org
Tue Mar 21 12:46:44 EDT 2023


https://github.com/python/cpython/commit/910a64e3013bce821bfac75377cbe88bedf265de
commit: 910a64e3013bce821bfac75377cbe88bedf265de
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2023-03-21T09:46:24-07:00
summary:

gh-102595: Document `PyObject_Format` c-api function (GH-102596)



Def: https://github.com/python/cpython/blame/5ffdaf748d98da6065158534720f1996a45a0072/Include/abstract.h#L389

files:
M Doc/c-api/object.rst

diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst
index 84c72e7e108b..0a12bb9e8c54 100644
--- a/Doc/c-api/object.rst
+++ b/Doc/c-api/object.rst
@@ -179,6 +179,15 @@ Object Protocol
    If *o1* and *o2* are the same object, :c:func:`PyObject_RichCompareBool`
    will always return ``1`` for :const:`Py_EQ` and ``0`` for :const:`Py_NE`.
 
+.. c:function:: PyObject* PyObject_Format(PyObject *obj, PyObject *format_spec)
+
+   Format *obj* using *format_spec*. This is equivalent to the Python
+   expression ``format(obj, format_spec)``.
+
+   *format_spec* may be ``NULL``. In this case the call is equivalent
+   to ``format(obj)``.
+   Returns the formatted string on success, ``NULL`` on failure.
+
 .. c:function:: PyObject* PyObject_Repr(PyObject *o)
 
    .. index:: builtin: repr



More information about the Python-checkins mailing list