Migrate from codecs.open() to io.open().
authorZac Medico <zmedico@gentoo.org>
Sun, 10 Jul 2011 23:26:24 +0000 (16:26 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 10 Jul 2011 23:55:05 +0000 (16:55 -0700)
commit8cc8d12a674ab6271183e5c35202263a36497279
tree22365e2c613d04151a2d2da5ff3e25e37f84c554
parent906b62b24d8a845356d59abc5acd39db2174ce0f
Migrate from codecs.open() to io.open().

The io.open() function is the same as the built-in open() function in
python3, and its implementation is optimized in python-2.7 and later.
In addition to the possible performance improvement, this also allows
us to avoid any future compatibility issues with codecs.open() that
may arise if it is delegated to the built-in open() function as
discussed in PEP 400.

The main caveat involved with io.open() is that TextIOWrapper.write()
raises TypeError if given raw bytes, unlike the streams returned from
codecs.open(). This is mainly an issue for python2 since literal
strings are raw bytes. We handle this by wrapping TextIOWrapper.write()
arguments with our _unicode_decode() function. Also, the
atomic_ofstream class overrides the write() method in python2 so that
it performs automatic coercion to unicode when necessary.
34 files changed:
bin/binhost-snapshot
bin/egencache
bin/repoman
pym/_emerge/Binpkg.py
pym/_emerge/EbuildFetcher.py
pym/_emerge/EbuildMetadataPhase.py
pym/_emerge/depgraph.py
pym/_emerge/emergelog.py
pym/_emerge/resolver/output_helpers.py
pym/portage/cache/flat_hash.py
pym/portage/cache/flat_list.py
pym/portage/cvstree.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/elog/messages.py
pym/portage/elog/mod_save.py
pym/portage/elog/mod_save_summary.py
pym/portage/env/loaders.py
pym/portage/glsa.py
pym/portage/manifest.py
pym/portage/news.py
pym/portage/output.py
pym/portage/package/ebuild/_config/LocationsManager.py
pym/portage/package/ebuild/deprecated_profile_check.py
pym/portage/package/ebuild/doebuild.py
pym/portage/package/ebuild/fetch.py
pym/portage/repository/config.py
pym/portage/tests/ebuild/test_spawn.py
pym/portage/update.py
pym/portage/util/ExtractKernelVersion.py
pym/portage/util/__init__.py
pym/portage/util/env_update.py
pym/repoman/utilities.py