Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Try to emphasize that strings with surrogate escapes cannot be passed…
… to sqlite3 API
  • Loading branch information
erlend-aasland committed Aug 31, 2023
commit 62073e5364c49d6acb85fe6e7dd0d95b22173afd
7 changes: 5 additions & 2 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2640,8 +2640,11 @@ The loop above will print the offending line using Unicode surrogate escapes:
INSERT INTO "test" VALUES('a\udc9f');
COMMIT;

Note that in order to write the invalid Unicode sequence to a file,
you will also have to use ``errors="surrogateescape"`` as an argument to :func:`open`:
Note that strings containing surrogate escapes must be treated with care.
You cannot pass them back to SQLite, for example using :meth:`~Cursor.execute`,
since the :mod:`!sqlite3` module APIs only accept UTF-8 encoded strings.
In order to write strings containing surrogate escapes to a file,
you will have to use ``errors="surrogateescape"`` as an argument to :func:`open`:

.. testcode::

Expand Down