Bug #299095 - Always use UTF-8 codec when opening ebuilds, to avoid
authorZac Medico <zmedico@gentoo.org>
Sun, 14 Mar 2010 23:44:14 +0000 (23:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 14 Mar 2010 23:44:14 +0000 (23:44 -0000)
UnicodeDecodeError with python3.

svn path=/main/trunk/; revision=15828

bin/repoman

index a6ae9a08f300a810a6e97e03af2ea857c23b2d32..26ca6e36f31cb9fb2c6842a8a0fd645ac7f2409f 100755 (executable)
@@ -2314,7 +2314,9 @@ else:
        from portage.util import write_atomic
        cvs_header = re.compile(r'^#\s*\$Header.*\$$')
        for x in myheaders:
-               f = open(x)
+               f = codecs.open(_unicode_encode(x,
+                       encoding=_encodings['fs'], errors='strict'),
+                       mode='r', encoding=_encodings['repo.content'], errors='strict')
                mylines = f.readlines()
                f.close()
                modified = False
@@ -2323,7 +2325,8 @@ else:
                                mylines[i] = line.replace("/Attic/", "/")
                                modified = True
                if modified:
-                       write_atomic(x, "".join(mylines))
+                       write_atomic(x, "".join(mylines),
+                               encoding=_encodings['repo.content'], errors='strict')
 
        manifest_commit_required = True
        if vcs in ('cvs', 'svn') and (myupdates or myremoved):