summaryrefslogtreecommitdiffstats
path: root/Doc/lib/sqlite3/text_factory.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-08-07 01:20:21 (GMT)
committerCollin Winter <collinw@gmail.com>2007-08-07 01:20:21 (GMT)
commit45d569b8232d19b0f6bd1385e8fb624f310d230e (patch)
tree610eda1d0c574f81bed24f2ceceecb0abf2ca1e5 /Doc/lib/sqlite3/text_factory.py
parentb942d28bf5b62e1823b91a7b3986e120ec9763bc (diff)
downloadcpython-45d569b8232d19b0f6bd1385e8fb624f310d230e.zip
cpython-45d569b8232d19b0f6bd1385e8fb624f310d230e.tar.gz
cpython-45d569b8232d19b0f6bd1385e8fb624f310d230e.tar.bz2
Run 2to3 over Doc/lib/sqlite3/.
Diffstat (limited to 'Doc/lib/sqlite3/text_factory.py')
-rw-r--r--Doc/lib/sqlite3/text_factory.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/lib/sqlite3/text_factory.py b/Doc/lib/sqlite3/text_factory.py
index 3e157a8..2dab8e4 100644
--- a/Doc/lib/sqlite3/text_factory.py
+++ b/Doc/lib/sqlite3/text_factory.py
@@ -6,7 +6,7 @@ cur = con.cursor()
# Create the table
con.execute("create table person(lastname, firstname)")
-AUSTRIA = u"\xd6sterreich"
+AUSTRIA = "\xd6sterreich"
# by default, rows are returned as Unicode
cur.execute("select ?", (AUSTRIA,))
@@ -25,17 +25,17 @@ assert row[0] == AUSTRIA.encode("utf-8")
# we can also implement a custom text_factory ...
# here we implement one that will ignore Unicode characters that cannot be
# decoded from UTF-8
-con.text_factory = lambda x: unicode(x, "utf-8", "ignore")
-cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),))
+con.text_factory = lambda x: str(x, "utf-8", "ignore")
+cur.execute("select ?", ("this is latin1 and would normally create errors" + "\xe4\xf6\xfc".encode("latin1"),))
row = cur.fetchone()
-assert type(row[0]) == unicode
+assert type(row[0]) == str
# pysqlite offers a builtin optimized text_factory that will return bytestring
# objects, if the data is in ASCII only, and otherwise return unicode objects
con.text_factory = sqlite3.OptimizedUnicode
cur.execute("select ?", (AUSTRIA,))
row = cur.fetchone()
-assert type(row[0]) == unicode
+assert type(row[0]) == str
cur.execute("select ?", ("Germany",))
row = cur.fetchone()