summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-30 20:05:57 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-30 20:05:57 +0000
commitc41fc8bbdefa7fe0c64bea302f1fdfd3f60b5b01 (patch)
treef38b11a6f6d11d13fe9d5039750194aef518c7af
parentdd9eae496d76a7691f1c16fc5fa251fa9a0ed4de (diff)
downloadportage-c41fc8bbdefa7fe0c64bea302f1fdfd3f60b5b01.tar.gz
portage-c41fc8bbdefa7fe0c64bea302f1fdfd3f60b5b01.tar.bz2
portage-c41fc8bbdefa7fe0c64bea302f1fdfd3f60b5b01.zip
Bug #283223 - Don't call str() on unicode strings inside _db_escape_string(),
since it can trigger a UnicodeEncodeError in python-2.x. svn path=/main/trunk/; revision=14172
-rw-r--r--pym/portage/cache/sqlite.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pym/portage/cache/sqlite.py b/pym/portage/cache/sqlite.py
index 81c076257..d27a7b006 100644
--- a/pym/portage/cache/sqlite.py
+++ b/pym/portage/cache/sqlite.py
@@ -47,7 +47,11 @@ class database(fs_template.FsBased):
def _db_escape_string(self, s):
"""meta escaping, returns quoted string for use in sql statements"""
- # This is equivalent to the _quote function from pysqlite 1.1.
+ if not isinstance(s, basestring):
+ # Avoid potential UnicodeEncodeError in python-2.x by
+ # only calling str() when it's absolutely necessary.
+ s = str(s)
+ # This is equivalent to the _quote function from pysqlite 1.1.
return "'%s'" % s.replace("'", "''")
def _db_init_connection(self, config):