diff options
author | Erlend E. Aasland <erlend@python.org> | 2023-08-30 14:53:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-30 14:53:10 (GMT) |
commit | 2a3926fa51b7264787d5988abf083d8c4328f4ad (patch) | |
tree | 8979134fd198d6802bb75ed1989b81f2e437e16a /Lib/sqlite3 | |
parent | 2928e5dc6512e4206c616cd33e0bcc3288abf6ed (diff) | |
download | cpython-2a3926fa51b7264787d5988abf083d8c4328f4ad.zip cpython-2a3926fa51b7264787d5988abf083d8c4328f4ad.tar.gz cpython-2a3926fa51b7264787d5988abf083d8c4328f4ad.tar.bz2 |
gh-108590: Revert gh-108657 (commit 400a1cebc) (#108686)
Reverted per Serhiy's request.
Diffstat (limited to 'Lib/sqlite3')
-rw-r--r-- | Lib/sqlite3/dump.py | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py index 481d605..ead3360 100644 --- a/Lib/sqlite3/dump.py +++ b/Lib/sqlite3/dump.py @@ -7,10 +7,6 @@ # 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('"', '""')) @@ -19,24 +15,6 @@ 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 - con.text_factory = factory - try: - yield - finally: - con.text_factory = saved_factory - - def _iterdump(connection): """ Returns an iterator to the dump of the database in an SQL text format. @@ -96,9 +74,8 @@ def _iterdump(connection): ) ) query_res = cu.execute(q) - with _text_factory(connection, bytes): - for row in query_res: - yield("{0};".format(_force_decode(row[0]))) + for row in query_res: + yield("{0};".format(row[0])) # Now when the type is 'index', 'trigger', or 'view' q = """ |