Skip to content

Commit 8c0f2f8

Browse files
committed
Document PyBytes_Repr().
1 parent 7211a34 commit 8c0f2f8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Doc/c-api/bytes.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ called with a non-bytes parameter.
228228
The function is :term:`soft deprecated`,
229229
use the :c:type:`PyBytesWriter` API instead.
230230
231+
232+
.. c:function:: PyObject *PyBytes_Repr(PyObject *bytes, int smartquotes)
233+
234+
Get the string representation of *bytes*. This function is used to
235+
implement :meth:`bytes.__repr__` in Python.
236+
237+
If *smartquotes* is true, the representation will use a double-quoted string
238+
instead of single-quoted string when single-quotes are present in *bytes*.
239+
For example, the byte string ``'Python'`` would be represented as
240+
``b"'Python'"`` when *smartquotes* is true, or b'\'Python\'' when it is
241+
false.
242+
243+
On success, this function returns a :term:`strong reference` to a
244+
:class:`str` object containing the representation. On failure, this
245+
returns ``NULL`` with an exception set.
246+
247+
231248
.. _pybyteswriter:
232249
233250
PyBytesWriter

0 commit comments

Comments
 (0)