@@ -201,3 +201,38 @@ called with a non-bytes parameter.
201201 reallocation fails, the original bytes object at *\* bytes * is deallocated,
202202 *\* bytes * is set to ``NULL ``, :exc: `MemoryError ` is set, and ``-1 `` is
203203 returned.
204+
205+
206+ .. c :function :: PyObject *PyBytes_Repr (PyObject *bytes, int smartquotes)
207+
208+ Get the string representation of *bytes *. This function is currently used to
209+ implement :meth: `!bytes.__repr__ ` in Python.
210+
211+ This function does not do type checking; it is undefined behavior to pass
212+ *bytes * as a non-bytes object or ``NULL ``.
213+
214+ If *smartquotes * is true, the representation will use a double-quoted string
215+ instead of single-quoted string when single-quotes are present in *bytes *.
216+ For example, the byte string ``'Python' `` would be represented as
217+ ``b"'Python'" `` when *smartquotes * is true, or ``b'\'Python\'' `` when it is
218+ false.
219+
220+ On success, this function returns a :term: `strong reference ` to a
221+ :class: `str ` object containing the representation. On failure, this
222+ returns ``NULL `` with an exception set.
223+
224+
225+ .. c :function :: PyObject *PyBytes_DecodeEscape (const char *s, Py_ssize_t len, const char *errors, Py_ssize_t unicode, const char *recode_encoding)
226+
227+ Unescape a backslash-escaped string *s *. *s * must not be ``NULL ``.
228+ *len * must be the size of *s *.
229+
230+ *errors * must be one of ``"strict" ``, ``"replace" ``, or ``"ignore" ``. If
231+ *errors * is ``NULL ``, then ``"strict" `` is used by default.
232+
233+ On success, this function returns a :term: `strong reference ` to a Python
234+ :class: `bytes ` object containing the unescaped string. On failure, this
235+ function returns ``NULL `` with an exception set.
236+
237+ .. versionchanged :: 3.9
238+ *unicode * and *recode_encoding * are now unused.
0 commit comments