Make isvalidatom() identify empty slot as invalid (missing slot is valid) and
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 05:57:35 +0000 (05:57 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 05:57:35 +0000 (05:57 -0000)
add a corresponding test case. (trunk r12654)

svn path=/main/branches/2.1.6/; revision=12922

pym/portage/dep.py
pym/portage/tests/dep/test_isvalidatom.py

index 04817068c0b587aa12c754f3323214a43445bc9e..22fa8bf56dfbf40010554bfff2a26f297dc1170c 100644 (file)
@@ -773,6 +773,10 @@ def isvalidatom(atom, allow_blockers=False):
                else:
                        atom = atom[1:]
 
+       if dep_getslot(atom) == "":
+               # empty slot is invalid (None is valid)
+               return 0
+
        try:
                use = dep_getusedeps(atom)
                if use:
index 1364a92a2d34fb537949f730f3ed16619eb18afa..5d6b4e73a12692a32386c50eeaf5be9a82ea2986 100644 (file)
@@ -25,6 +25,7 @@ class IsValidAtom(TestCase):
                          ( "sys-apps/portage:foo", True ),
                          ( "sys-apps/portage-2.1:foo", False ),
                          ( "sys-apps/portage-2.1:", False ),
+                         ( "sys-apps/portage-2.1:[foo]", False ),
                          ( "=sys-apps/portage-2.2*:foo[bar?,!baz?,!doc=,build=]", True ),
                          ( "=sys-apps/portage-2.2*:foo[doc?]", True ),
                          ( "=sys-apps/portage-2.2*:foo[!doc?]", True ),