Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a3926f

Browse files
gh-108590: Revert gh-108657 (commit 400a1ce) (#108686)
Reverted per Serhiy's request.
1 parent 2928e5d commit 2a3926f

File tree

3 files changed

+2
-41
lines changed

3 files changed

+2
-41
lines changed

Lib/sqlite3/dump.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
# future enhancements, you should normally quote any identifier that
88
# is an English language word, even if you do not have to."
99

10-
11-
from contextlib import contextmanager
12-
13-
1410
def _quote_name(name):
1511
return '"{0}"'.format(name.replace('"', '""'))
1612

@@ -19,24 +15,6 @@ def _quote_value(value):
1915
return "'{0}'".format(value.replace("'", "''"))
2016

2117

22-
def _force_decode(bs, *args, **kwargs):
23-
# gh-108590: Don't fail if the database contains invalid Unicode data.
24-
try:
25-
return bs.decode(*args, **kwargs)
26-
except UnicodeDecodeError:
27-
return "".join([chr(c) for c in bs])
28-
29-
30-
@contextmanager
31-
def _text_factory(con, factory):
32-
saved_factory = con.text_factory
33-
con.text_factory = factory
34-
try:
35-
yield
36-
finally:
37-
con.text_factory = saved_factory
38-
39-
4018
def _iterdump(connection):
4119
"""
4220
Returns an iterator to the dump of the database in an SQL text format.
@@ -96,9 +74,8 @@ def _iterdump(connection):
9674
)
9775
)
9876
query_res = cu.execute(q)
99-
with _text_factory(connection, bytes):
100-
for row in query_res:
101-
yield("{0};".format(_force_decode(row[0])))
77+
for row in query_res:
78+
yield("{0};".format(row[0]))
10279

10380
# Now when the type is 'index', 'trigger', or 'view'
10481
q = """

Lib/test/test_sqlite3/test_dump.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,6 @@ def test_dump_virtual_tables(self):
133133
actual = list(self.cx.iterdump())
134134
self.assertEqual(expected, actual)
135135

136-
def test_dump_unicode_invalid(self):
137-
# gh-108590
138-
expected = [
139-
"BEGIN TRANSACTION;",
140-
"CREATE TABLE foo (data TEXT);",
141-
"INSERT INTO \"foo\" VALUES('a\x9f');",
142-
"COMMIT;",
143-
]
144-
self.cu.executescript("""
145-
CREATE TABLE foo (data TEXT);
146-
INSERT INTO foo VALUES (CAST(X'619f' AS TEXT));
147-
""")
148-
actual = list(self.cx.iterdump())
149-
self.assertEqual(expected, actual)
150-
151136

152137
if __name__ == "__main__":
153138
unittest.main()

Misc/NEWS.d/next/Library/2023-08-29-22-53-48.gh-issue-108590.6k0pOl.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)