For bug #181355, detect parenthesis mismatch in paren_reduce(), raise an InvalidDepen...
authorZac Medico <zmedico@gentoo.org>
Mon, 11 Jun 2007 02:49:15 +0000 (02:49 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 11 Jun 2007 02:49:15 +0000 (02:49 -0000)
svn path=/main/branches/2.1.2/; revision=6798

bin/repoman
pym/portage.py
pym/portage_dep.py

index 3a939d9ace93dbbd3b61a418c6d255db5756e120..c033a0d44815718baba5df2e53582606dc89a136 100755 (executable)
@@ -1129,6 +1129,10 @@ for x in scanlist:
                        except ValueError:
                                badsyntax.append("parenthesis mismatch")
                                mydeplist = []
+                       except portage_exception.InvalidDependString, e:
+                               badsyntax.append(str(e))
+                               del e
+                               mydeplist = []
 
                        try:
                                portage_dep.use_reduce(mydeplist, excludeall=myiuse)
index c59edb941a88bca4801a3b48d3133fa4f3a9a5e1..ee7b9c4a051fbde05f9f7297209543f60f118f5b 100644 (file)
@@ -3092,9 +3092,14 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
                if not eapi_is_supported(eapi):
                        # can't do anything with this.
                        raise portage_exception.UnsupportedAPIException(mycpv, eapi)
-               mysettings["PORTAGE_RESTRICT"] = " ".join(flatten(
-                       portage_dep.use_reduce(portage_dep.paren_reduce(
-                       mysettings["RESTRICT"]), uselist=mysettings["USE"].split())))
+               try:
+                       mysettings["PORTAGE_RESTRICT"] = " ".join(flatten(
+                               portage_dep.use_reduce(portage_dep.paren_reduce(
+                               mysettings.get("RESTRICT","")),
+                               uselist=mysettings.get("USE","").split())))
+               except portage_exception.InvalidDependString:
+                       # RESTRICT is validated again inside doebuild, so let this go
+                       mysettings["PORTAGE_RESTRICT"] = ""
 
        if mysplit[2] == "r0":
                mysettings["PVR"]=mysplit[1]
@@ -4398,7 +4403,10 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
                myusesplit=[]
 
        #convert parenthesis to sublists
-       mysplit = portage_dep.paren_reduce(depstring)
+       try:
+               mysplit = portage_dep.paren_reduce(depstring)
+       except portage_exception.InvalidDependString, e:
+               return [0, str(e)]
 
        mymasks = set()
        useforce = set()
index b87058f7f10c2e7c1114e0f096259578906b3e04..a8007857ed89b45a93400b9c89f661a4223df217 100644 (file)
@@ -69,13 +69,20 @@ def paren_reduce(mystr,tokenize=1):
        """
        mylist = []
        while mystr:
-               if ("(" not in mystr) and (")" not in mystr):
+               left_paren = mystr.find("(")
+               has_left_paren = left_paren != -1
+               right_paren = mystr.find(")")
+               has_right_paren = right_paren != -1
+               if not has_left_paren and not has_right_paren:
                        freesec = mystr
                        subsec = None
                        tail = ""
                elif mystr[0] == ")":
                        return [mylist,mystr[1:]]
-               elif ("(" in mystr) and (mystr.index("(") < mystr.index(")")):
+               elif has_left_paren and not has_right_paren:
+                       raise portage_exception.InvalidDependString(
+                               "missing right parenthesis: '%s'" % mystr)
+               elif has_left_paren and left_paren < right_paren:
                        freesec,subsec = mystr.split("(",1)
                        subsec,tail = paren_reduce(subsec,tokenize)
                else: