Bug #282306 - Inside dblink._find_libs_to_preserve(), fall back to utf_8
authorZac Medico <zmedico@gentoo.org>
Sun, 23 Aug 2009 07:25:40 +0000 (07:25 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 23 Aug 2009 07:25:40 +0000 (07:25 -0000)
encoding if a path cannot be encoded under the user's chosen encoding. This
fixes the traceback shown in bug 282115, comment #6.

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

pym/portage/dbapi/vartree.py

index aa74ed687e42327439e40b5580a8429ec4275f9c..e6ed16498fa4d21569ae8803725281f3afd2574c 100644 (file)
@@ -2717,6 +2717,23 @@ class dblink(object):
                provider_nodes = set()
                # Create provider nodes and add them to the graph.
                for f_abs in old_contents:
+
+                       if os is _os_merge:
+                               try:
+                                       _unicode_encode(f_abs,
+                                               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(f_abs,
+                                                       encoding=_encodings['fs'], errors='strict')
+                                       except UnicodeEncodeError:
+                                               pass
+                                       else:
+                                               os = portage.os
+
                        f = f_abs[root_len:]
                        if self.isowner(f, root):
                                continue