Add workaround for Python 2.6.4 issue 4978
authorZac Medico <zmedico@gentoo.org>
Fri, 18 Jan 2013 23:05:42 +0000 (15:05 -0800)
committerZac Medico <zmedico@gentoo.org>
Fri, 18 Jan 2013 23:05:42 +0000 (15:05 -0800)
Avoid "TypeError: keywords must be strings" issue triggered
by unicode_literals: http://bugs.python.org/issue4978

pym/_emerge/depgraph.py
pym/_emerge/resolver/output.py
pym/portage/__init__.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/news.py
pym/portage/package/ebuild/doebuild.py
pym/portage/repository/config.py
pym/repoman/checks.py

index b5dba31dc41b55e36b9448b05e71120a9ebb8ea4..7a967957c1f64debafb873c96bf8fb642e1c624c 100644 (file)
@@ -2971,7 +2971,8 @@ class depgraph(object):
                not been scheduled for replacement.
                """
                kwargs["trees"] = self._dynamic_config._graph_trees
-               return self._select_atoms_highest_available(*pargs, **kwargs)
+               return self._select_atoms_highest_available(*pargs,
+                       **portage._native_kwargs(kwargs))
 
        def _select_atoms_highest_available(self, root, depstring,
                myuse=None, parent=None, strict=True, trees=None, priority=None):
@@ -6813,7 +6814,8 @@ class depgraph(object):
                        writemsg("\n", noiselevel=-1)
 
                for pargs, kwargs in self._dynamic_config._unsatisfied_deps_for_display:
-                       self._show_unsatisfied_dep(*pargs, **kwargs)
+                       self._show_unsatisfied_dep(*pargs,
+                               **portage._native_kwargs(kwargs))
 
        def saveNomergeFavorites(self):
                """Find atoms in favorites that are not in the mergelist and add them
@@ -7158,7 +7160,8 @@ class depgraph(object):
                try:
                        for pargs, kwargs in self._dynamic_config._unsatisfied_deps_for_display:
                                self._show_unsatisfied_dep(
-                                       *pargs, check_autounmask_breakage=True, **kwargs)
+                                       *pargs, check_autounmask_breakage=True,
+                                       **portage._native_kwargs(kwargs))
                except self._autounmask_breakage:
                        return True
                return False
index 651a4f73c5309f63449c2c3d3a0bfc63e5c3bef5..6aeadee943366e9fdb7c985beeae2a6ccf6d97da 100644 (file)
@@ -12,6 +12,7 @@ __all__ = (
 
 import sys
 
+import portage
 from portage import os
 from portage.dbapi.dep_expand import dep_expand
 from portage.dep import cpvequal, _repo_separator, _slot_separator
@@ -316,7 +317,8 @@ class Display(object):
                                kwargs["myrepo"] = pkg.repo
                        myfilesdict = None
                        try:
-                               myfilesdict = db.getfetchsizes(pkg.cpv, **kwargs)
+                               myfilesdict = db.getfetchsizes(pkg.cpv,
+                                       **portage._native_kwargs(kwargs))
                        except InvalidDependString as e:
                                # FIXME: validate SRC_URI earlier
                                depstr, = db.aux_get(pkg.cpv,
index 3bae4defff20004c935e08d67e0faa22f2794bcd..94ca7b90f1b821daad5adb14c44e8ee884c83960 100644 (file)
@@ -198,6 +198,15 @@ else:
 
        _native_string = _unicode_encode
 
+if sys.hexversion >= 0x20605f0:
+       def _native_kwargs(kwargs):
+               return kwargs
+else:
+       # Avoid "TypeError: keywords must be strings" issue triggered
+       # by unicode_literals: http://bugs.python.org/issue4978
+       def _native_kwargs(kwargs):
+               return dict((_native_string(k), v) for k, v in kwargs.iteritems())
+
 class _unicode_func_wrapper(object):
        """
        Wraps a function, converts arguments from unicode to bytes,
index 321b6758aa1cf1cfa3cd61a3afb65f1b4d0e6027..e21e53ce61059867a1e9a9e9c897ec87f1cf729b 100644 (file)
@@ -155,10 +155,10 @@ class portdbapi(dbapi):
                        # portage group.
                        depcachedir_unshared = True
                else:
-                       cache_kwargs.update({
+                       cache_kwargs.update(portage._native_kwargs({
                                'gid'     : portage_gid,
                                'perms'   : 0o664
-                       })
+                       }))
 
                # If secpass < 1, we don't want to write to the cache
                # since then we won't be able to apply group permissions
index 30add8a89abf738f0de2a8b6c077e5b24390bdc6..20a114bdad27195750d026fbe589db1a80462bcd 100644 (file)
@@ -4837,7 +4837,8 @@ class dblink(object):
                else:
                        kwargs['mode'] = 'w'
                        kwargs['encoding'] = _encodings['repo.content']
-               write_atomic(os.path.join(self.dbdir, fname), data, **kwargs)
+               write_atomic(os.path.join(self.dbdir, fname), data,
+                       **portage._native_kwargs(kwargs))
 
        def getelements(self,ename):
                if not os.path.exists(self.dbdir+"/"+ename):
index 94ec8f1648110d723f724d71af163e6ccf7cd875..408fb5c5fe74feb6907c5c6b095bed6fc8e5a4a0 100644 (file)
@@ -13,6 +13,7 @@ import io
 import logging
 import os as _os
 import re
+import portage
 from portage import OrderedDict
 from portage import os
 from portage import _encodings
@@ -241,7 +242,8 @@ class NewsItem(object):
                for values in self.restrictions.values():
                        any_match = False
                        for restriction in values:
-                               if restriction.checkRestriction(**kwargs):
+                               if restriction.checkRestriction(
+                                       **portage._native_kwargs(kwargs)):
                                        any_match = True
                        if not any_match:
                                all_match = False
index 3e8ff013847f397ac540f9029f4d01f2ad06faa9..71a6f156f37ed9591fe60d7926e6a984c13446a6 100644 (file)
@@ -135,7 +135,7 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs):
 
        settings['EBUILD_PHASE'] = phase
        try:
-               return spawn(cmd, settings, **kwargs)
+               return spawn(cmd, settings, **portage._native_kwargs(kwargs))
        finally:
                settings.pop('EBUILD_PHASE', None)
 
@@ -1453,14 +1453,15 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero
                        mysettings["PORTAGE_SANDBOX_T"])
 
        if keywords.get("returnpid"):
-               return spawn_func(mystring, env=mysettings.environ(), **keywords)
+               return spawn_func(mystring, env=mysettings.environ(),
+                       **portage._native_kwargs(keywords))
 
        proc = EbuildSpawnProcess(
                background=False, args=mystring,
                scheduler=SchedulerInterface(portage._internal_caller and
                        global_event_loop() or EventLoop(main=False)),
                spawn_func=spawn_func,
-               settings=mysettings, **keywords)
+               settings=mysettings, **portage._native_kwargs(keywords))
 
        proc.start()
        proc.wait()
index a1c1f79cee10819de57eb5234f8c303de16ecaf3..8a110e990688fa263520aa1e9597b17b16a35029 100644 (file)
@@ -238,7 +238,7 @@ class RepoConfig(object):
                if self.disable_manifest:
                        kwds['from_scratch'] = True
                kwds['find_invalid_path_char'] = self.find_invalid_path_char
-               return manifest.Manifest(*args, **kwds)
+               return manifest.Manifest(*args, **portage._native_kwargs(kwds))
 
        def update(self, new_repo):
                """Update repository with options in another RepoConfig"""
index 83ce2ed6e7199bcd5f8557c483c6045626c7d3b2..9dd3b959d6f078b30f26212e56b02a3ab30ed5a7 100644 (file)
@@ -819,7 +819,8 @@ class PortageInternalVariableAssignment(LineCheck):
 _base_check_classes = (InheritEclass, LineCheck, PhaseCheck)
 _constant_checks = tuple(chain((v() for k, v in globals().items()
        if isinstance(v, type) and issubclass(v, LineCheck) and v not in _base_check_classes),
-       (InheritEclass(k, **kwargs) for k, kwargs in _eclass_info.items())))
+       (InheritEclass(k, **portage._native_kwargs(kwargs))
+       for k, kwargs in _eclass_info.items())))
 
 _here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
 _ignore_comment_re = re.compile(r'^\s*#')