#15109: revert '%'->'format' changes in 4b105d328fe7 to fix regression.
With '%', non-ascii worked because the '%' automatically got promoted to
unicode. With format that doesn't happen, which led to encoding errors. This
fix goes back to using %, and adds a test to make sure non-ascii string values
work in iterdump.
diff --git a/Lib/sqlite3/dump.py b/Lib/sqlite3/dump.py
index de9c368..e5c5ef2 100644
--- a/Lib/sqlite3/dump.py
+++ b/Lib/sqlite3/dump.py
@@ -43,7 +43,7 @@
# qtable,
# sql.replace("''")))
else:
- yield('{0};'.format(sql))
+ yield('%s;' % sql)
# Build the insert statement for each row of the current table
table_name_ident = table_name.replace('"', '""')
@@ -54,7 +54,7 @@
",".join("""'||quote("{0}")||'""".format(col.replace('"', '""')) for col in column_names))
query_res = cu.execute(q)
for row in query_res:
- yield("{0};".format(row[0]))
+ yield("%s;" % row[0])
# Now when the type is 'index', 'trigger', or 'view'
q = """
@@ -65,6 +65,6 @@
"""
schema_res = cu.execute(q)
for name, type, sql in schema_res.fetchall():
- yield('{0};'.format(sql))
+ yield('%s;' % sql)
yield('COMMIT;')
diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py
index 195c139..b7de810 100644
--- a/Lib/sqlite3/test/dump.py
+++ b/Lib/sqlite3/test/dump.py
@@ -29,6 +29,8 @@
,
"INSERT INTO \"t1\" VALUES(2,'foo2',30,30);"
,
+ u"INSERT INTO \"t1\" VALUES(3,'f\xc3\xb6',40,10);"
+ ,
"CREATE TABLE t2(id integer, t2_i1 integer, " \
"t2_i2 integer, primary key (id)," \
"foreign key(t2_i1) references t1(t1_i1));"