@@ -228,6 +228,42 @@ 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 currently used to
235+ implement :meth: `!bytes.__repr__ ` in Python.
236+
237+ This function does not do type checking; it is undefined behavior to pass
238+ *bytes * as a non-bytes object or ``NULL ``.
239+
240+ If *smartquotes * is true, the representation will use a double-quoted string
241+ instead of single-quoted string when single-quotes are present in *bytes *.
242+ For example, the byte string ``'Python' `` would be represented as
243+ ``b"'Python'" `` when *smartquotes * is true, or ``b'\'Python\'' `` when it is
244+ false.
245+
246+ On success, this function returns a :term: `strong reference ` to a
247+ :class: `str ` object containing the representation. On failure, this
248+ returns ``NULL `` with an exception set.
249+
250+
251+ .. c :function :: PyObject *PyBytes_DecodeEscape (const char *s, Py_ssize_t len, const char *errors, Py_ssize_t unicode, const char *recode_encoding)
252+
253+ Unescape a backslash-escaped string *s *. *s * must not be ``NULL ``.
254+ *len * must be the size of *s *.
255+
256+ *errors * must be one of ``"strict" ``, ``"replace" ``, or ``"ignore" ``. If
257+ *errors * is ``NULL ``, then ``"strict" `` is used by default.
258+
259+ On success, this function returns a :term: `strong reference ` to a Python
260+ :class: `bytes ` object containing the unescaped string. On failure, this
261+ function returns ``NULL `` with an exception set.
262+
263+ .. versionchanged :: 3.9
264+ *unicode * and *recode_encoding * are now unused.
265+
266+
231267.. _pybyteswriter :
232268
233269PyBytesWriter
0 commit comments