]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
persist_data: Return str instead of unicode for sqlite3 text queries
authorKlauer, Daniel <Daniel.Klauer@gin.de>
Tue, 5 Apr 2016 08:49:15 +0000 (08:49 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 5 Apr 2016 13:36:46 +0000 (14:36 +0100)
Python 2's sqlite3 module defaults to returning Unicode strings for SQL
text queries, which could trickle down to other parts of bitbake code and
cause unexpected Unicode conversions. Using byte strings avoids this issue.

For example, the git fetcher's AUTOREV support caches HEAD SHA1's using
bb.persist_data, so sometimes the git command strings passed to fetch2's
runfetchcmd() were unicode, potentially causing UnicodeDecodeErrors when
it appended the values of environment variables containing non-ASCII chars.

[YOCTO #9382]

Signed-off-by: Daniel Klauer <daniel.klauer@gin.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/persist_data.py

index 5795bc835bf925af93f6d99adf5d3864cc17249b..e45042324e7328335c0b8c3a3fe70f7667036081 100644 (file)
@@ -201,6 +201,7 @@ class PersistData(object):
 def connect(database):
     connection = sqlite3.connect(database, timeout=5, isolation_level=None)
     connection.execute("pragma synchronous = off;")
+    connection.text_factory = str
     return connection
 
 def persist(domain, d):