summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-18 09:12:25 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-18 09:12:25 -0800
commit417692f361be32de353bc4d698b43d7a8121ec6d (patch)
tree2bd4c299c95709f4666aa9523d6db1ed579daee1
parent729a0d126771fc5aaae38b1221dad1aebe15345e (diff)
downloadportage-417692f361be32de353bc4d698b43d7a8121ec6d.tar.gz
portage-417692f361be32de353bc4d698b43d7a8121ec6d.tar.bz2
portage-417692f361be32de353bc4d698b43d7a8121ec6d.zip
cache/flat_hash.py: unicode_literals
-rw-r--r--pym/portage/cache/flat_hash.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py
index b1c94313b..08dcbe8e1 100644
--- a/pym/portage/cache/flat_hash.py
+++ b/pym/portage/cache/flat_hash.py
@@ -1,7 +1,9 @@
-# Copyright: 2005-2012 Gentoo Foundation
+# Copyright: 2005-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Author(s): Brian Harring (ferringb@gentoo.org)
+from __future__ import unicode_literals
+
from portage.cache import fs_template
from portage.cache import cache_errors
import errno
@@ -11,7 +13,6 @@ import sys
import os as _os
from portage import os
from portage import _encodings
-from portage import _unicode_decode
from portage import _unicode_encode
from portage.exception import InvalidData
from portage.versions import _pkg_str
@@ -19,10 +20,6 @@ from portage.versions import _pkg_str
if sys.hexversion >= 0x3000000:
long = int
-# Coerce to unicode, in order to prevent TypeError when writing
-# raw bytes to TextIOWrapper with python2.
-_setitem_fmt = _unicode_decode("%s=%s\n")
-
class database(fs_template.FsBased):
autocommits = True
@@ -93,7 +90,10 @@ class database(fs_template.FsBased):
v = values.get(k)
if not v:
continue
- myf.write(_setitem_fmt % (k, v))
+ # NOTE: This format string requires unicode_literals, so that
+ # k and v are coerced to unicode, in order to prevent TypeError
+ # when writing raw bytes to TextIOWrapper with Python 2.
+ myf.write("%s=%s\n" % (k, v))
finally:
myf.close()
self._ensure_access(fp)