Merged from trunk -r14130:14131
authorFabian Groffen <grobian@gentoo.org>
Mon, 24 Aug 2009 09:44:30 +0000 (09:44 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 24 Aug 2009 09:44:30 +0000 (09:44 -0000)
   | 14131   | Bug #282306 - Inside                                         |
   | zmedico | LinkageMap._ObjectKey._generate_object_key(), fall back to   |
   |         | utf_8 encoding if a path cannot be encoded under the user's  |
   |         | chosen encoding. This should complete the fix for the        |
   |         | traceback shown in bug #282115, comment #6.                  |

svn path=/main/branches/prefix/; revision=14146

pym/portage/dbapi/vartree.py

index a11cb39d2810942bb636d7d56852b0ed81bee92f..9188970b47abdf5dabca5057467fb25ec0d33109 100644 (file)
@@ -250,6 +250,21 @@ class LinkageMap(object):
 
                        os = _os_merge
 
+                       try:
+                               _unicode_encode(obj,
+                                       encoding=_encodings['merge'], errors='strict')
+                       except UnicodeEncodeError:
+                               # The package appears to have been merged with a 
+                               # different value of sys.getfilesystemencoding(),
+                               # so fall back to utf_8 if appropriate.
+                               try:
+                                       _unicode_encode(obj,
+                                               encoding=_encodings['fs'], errors='strict')
+                               except UnicodeEncodeError:
+                                       pass
+                               else:
+                                       os = portage.os
+
                        abs_path = os.path.join(root, obj.lstrip(os.sep))
                        try:
                                object_stat = os.stat(abs_path)