Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r14172 - main/trunk/pym/portage/cache
Date: Sun, 30 Aug 2009 14:57:02
Message-Id: E1Mhqez-0000WI-PQ@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-08-30 20:05:57 +0000 (Sun, 30 Aug 2009)
3 New Revision: 14172
4
5 Modified:
6 main/trunk/pym/portage/cache/sqlite.py
7 Log:
8 Bug #283223 - Don't call str() on unicode strings inside _db_escape_string(),
9 since it can trigger a UnicodeEncodeError in python-2.x.
10
11
12 Modified: main/trunk/pym/portage/cache/sqlite.py
13 ===================================================================
14 --- main/trunk/pym/portage/cache/sqlite.py 2009-08-30 10:36:51 UTC (rev 14171)
15 +++ main/trunk/pym/portage/cache/sqlite.py 2009-08-30 20:05:57 UTC (rev 14172)
16 @@ -47,7 +47,11 @@
17
18 def _db_escape_string(self, s):
19 """meta escaping, returns quoted string for use in sql statements"""
20 - # This is equivalent to the _quote function from pysqlite 1.1.
21 + if not isinstance(s, basestring):
22 + # Avoid potential UnicodeEncodeError in python-2.x by
23 + # only calling str() when it's absolutely necessary.
24 + s = str(s)
25 + # This is equivalent to the _quote function from pysqlite 1.1.
26 return "'%s'" % s.replace("'", "''")
27
28 def _db_init_connection(self, config):