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
Style nits and a comment
  • Loading branch information
erlend-aasland committed Aug 30, 2023
commit c1b730d28abc136e550324d165aed0caef4e4b5b
6 changes: 6 additions & 0 deletions Lib/sqlite3/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@
# future enhancements, you should normally quote any identifier that
# is an English language word, even if you do not have to."


from contextlib import contextmanager


def _quote_name(name):
return '"{0}"'.format(name.replace('"', '""'))


def _quote_value(value):
return "'{0}'".format(value.replace("'", "''"))


def _force_decode(bs, *args, **kwargs):
# gh-108590: Don't fail if the database contains invalid Unicode data.
try:
return bs.decode(*args, **kwargs)
except UnicodeDecodeError:
return "".join([chr(c) for c in bs])


@contextmanager
def _text_factory(con, factory):
saved_factory = con.text_factory
Expand All @@ -31,6 +36,7 @@ def _text_factory(con, factory):
finally:
con.text_factory = saved_factory


def _iterdump(connection):
"""
Returns an iterator to the dump of the database in an SQL text format.
Expand Down