cpv_expand: fix KeyError when settings is None
authorZac Medico <zmedico@gentoo.org>
Fri, 8 Jul 2011 06:46:28 +0000 (23:46 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 8 Jul 2011 06:46:28 +0000 (23:46 -0700)
pym/portage/dbapi/cpv_expand.py

index 7077b1febee73851011e539e96662221ab8acb20..947194cca8270fa904b307a351afd5e6329f4987 100644 (file)
@@ -3,6 +3,7 @@
 
 __all__ = ["cpv_expand"]
 
+import portage
 from portage.exception import AmbiguousPackageName
 from portage.localization import _
 from portage.util import writemsg
@@ -16,7 +17,10 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
        myslash=mycpv.split("/")
        mysplit = _pkgsplit(myslash[-1])
        if settings is None:
-               settings = globals()["settings"]
+               try:
+                       settings = mydb.settings
+               except AttributeError:
+                       settings = portage.settings
        if len(myslash)>2:
                # this is illegal case.
                mysplit=[]