Bug #282306 - Inside LinkageMap._ObjectKey._generate_object_key(), fall back
authorZac Medico <zmedico@gentoo.org>
Sun, 23 Aug 2009 07:40:57 +0000 (07:40 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 23 Aug 2009 07:40:57 +0000 (07:40 -0000)
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/trunk/; revision=14131

pym/portage/dbapi/vartree.py

index e6ed16498fa4d21569ae8803725281f3afd2574c..5a2c3d0918b73dcc0528fbec9902d6ee80ec23d4 100644 (file)
@@ -249,6 +249,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)