@@ -219,3 +219,38 @@ called with a non-bytes parameter.
219219 reallocation fails, the original bytes object at *\* bytes * is deallocated,
220220 *\* bytes * is set to ``NULL ``, :exc: `MemoryError ` is set, and ``-1 `` is
221221 returned.
222+
223+
224+ .. c :function :: PyObject *PyBytes_Repr (PyObject *bytes, int smartquotes)
225+
226+ Get the string representation of *bytes *. This function is currently used to
227+ implement :meth: `!bytes.__repr__ ` in Python.
228+
229+ This function does not do type checking; it is undefined behavior to pass
230+ *bytes * as a non-bytes object or ``NULL ``.
231+
232+ If *smartquotes * is true, the representation will use a double-quoted string
233+ instead of single-quoted string when single-quotes are present in *bytes *.
234+ For example, the byte string ``'Python' `` would be represented as
235+ ``b"'Python'" `` when *smartquotes * is true, or ``b'\'Python\'' `` when it is
236+ false.
237+
238+ On success, this function returns a :term: `strong reference ` to a
239+ :class: `str ` object containing the representation. On failure, this
240+ returns ``NULL `` with an exception set.
241+
242+
243+ .. c :function :: PyObject *PyBytes_DecodeEscape (const char *s, Py_ssize_t len, const char *errors, Py_ssize_t unicode, const char *recode_encoding)
244+
245+ Unescape a backslash-escaped string *s *. *s * must not be ``NULL ``.
246+ *len * must be the size of *s *.
247+
248+ *errors * must be one of ``"strict" ``, ``"replace" ``, or ``"ignore" ``. If
249+ *errors * is ``NULL ``, then ``"strict" `` is used by default.
250+
251+ On success, this function returns a :term: `strong reference ` to a Python
252+ :class: `bytes ` object containing the unescaped string. On failure, this
253+ function returns ``NULL `` with an exception set.
254+
255+ .. versionchanged :: 3.9
256+ *unicode * and *recode_encoding * are now unused.
0 commit comments