From: Zac Medico Date: Fri, 28 Oct 2011 00:53:51 +0000 (-0700) Subject: create_trees: ensure trees is _trees_dict type X-Git-Tag: v2.2.0_alpha72~51 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=db1db3b011546e99e5248cb5f292b584eba26f03;p=portage.git create_trees: ensure trees is _trees_dict type --- diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 03ec28665..e4abab371 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -480,15 +480,13 @@ def portageexit(): close_portdbapi_caches() class _trees_dict(dict): - def __init__(self): - super(dict, self).__init__() + def __init__(self, *pargs, **kargs): + dict.__init__(self, *pargs, **kargs) self._running_eroot = None self._target_eroot = None def create_trees(config_root=None, target_root=None, trees=None, env=None): - if trees is None: - trees = _trees_dict() - else: + if trees is not None: # clean up any existing portdbapi instances for myroot in trees: portdb = trees[myroot]["porttree"].dbapi @@ -496,6 +494,13 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None): portdbapi.portdbapi_instances.remove(portdb) del trees[myroot]["porttree"], myroot, portdb + if trees is None: + trees = _trees_dict() + elif not isinstance(trees, _trees_dict): + # caller passed a normal dict or something, + # but we need a _trees_dict instance + trees = _trees_dict(trees) + if env is None: env = os.environ eprefix = env.get("__PORTAGE_TEST_EPREFIX")