mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.13] gh-141004: Document PyBytes_Repr and PyBytes_DecodeEscape (GH-141407) (GH-141441)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
* gh-141004: Document `PyBytes_Repr` and `PyBytes_DecodeEscape` (GH-141407)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
(cherry picked from commit 37e2762ee1)
This commit is contained in:
parent
aec6b72297
commit
51c60f3681
1 changed files with 35 additions and 0 deletions
|
|
@ -201,3 +201,38 @@ called with a non-bytes parameter.
|
|||
reallocation fails, the original bytes object at *\*bytes* is deallocated,
|
||||
*\*bytes* is set to ``NULL``, :exc:`MemoryError` is set, and ``-1`` is
|
||||
returned.
|
||||
|
||||
|
||||
.. c:function:: PyObject *PyBytes_Repr(PyObject *bytes, int smartquotes)
|
||||
|
||||
Get the string representation of *bytes*. This function is currently used to
|
||||
implement :meth:`!bytes.__repr__` in Python.
|
||||
|
||||
This function does not do type checking; it is undefined behavior to pass
|
||||
*bytes* as a non-bytes object or ``NULL``.
|
||||
|
||||
If *smartquotes* is true, the representation will use a double-quoted string
|
||||
instead of single-quoted string when single-quotes are present in *bytes*.
|
||||
For example, the byte string ``'Python'`` would be represented as
|
||||
``b"'Python'"`` when *smartquotes* is true, or ``b'\'Python\''`` when it is
|
||||
false.
|
||||
|
||||
On success, this function returns a :term:`strong reference` to a
|
||||
:class:`str` object containing the representation. On failure, this
|
||||
returns ``NULL`` with an exception set.
|
||||
|
||||
|
||||
.. c:function:: PyObject *PyBytes_DecodeEscape(const char *s, Py_ssize_t len, const char *errors, Py_ssize_t unicode, const char *recode_encoding)
|
||||
|
||||
Unescape a backslash-escaped string *s*. *s* must not be ``NULL``.
|
||||
*len* must be the size of *s*.
|
||||
|
||||
*errors* must be one of ``"strict"``, ``"replace"``, or ``"ignore"``. If
|
||||
*errors* is ``NULL``, then ``"strict"`` is used by default.
|
||||
|
||||
On success, this function returns a :term:`strong reference` to a Python
|
||||
:class:`bytes` object containing the unescaped string. On failure, this
|
||||
function returns ``NULL`` with an exception set.
|
||||
|
||||
.. versionchanged:: 3.9
|
||||
*unicode* and *recode_encoding* are now unused.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue