In getconfig(), specify utf_8 encoding for py3k.
authorZac Medico <zmedico@gentoo.org>
Thu, 6 Aug 2009 22:44:45 +0000 (22:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 6 Aug 2009 22:44:45 +0000 (22:44 -0000)
svn path=/main/trunk/; revision=13943

pym/portage/util.py

index 780c9b5f16f458af74cd08aad7d0d38e0ede5a5e..a12b8a18e2d76817b77cf72d62a83d187f015b6f 100644 (file)
@@ -387,7 +387,11 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
                # trailing newline after the source statement
                # NOTE: shex doesn't seem to supported unicode objects
                # (produces spurious \0 characters with python-2.6.2)
-               content = open(mycfg).read()
+               if sys.hexversion < 0x3000000:
+                       content = open(mycfg, 'rb').read()
+               else:
+                       content = open(mycfg, mode='r',
+                               encoding='utf_8', errors='replace').read()
                if content and content[-1] != '\n':
                        content += '\n'
        except IOError, e: