commit:     0e5ec943c8a237f38863387bcf7f0069fcbd44a9
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  3 14:42:00 2026 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Jan  3 14:42:00 2026 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=0e5ec943

cpv: fix valid category regex (dot as not first letter)

Resolves: https://github.com/pkgcore/pkgcore/issues/463
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/cpv.py | 8 ++------
 tests/ebuild/test_cpv.py  | 8 +++++---
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/pkgcore/ebuild/cpv.py b/src/pkgcore/ebuild/cpv.py
index 5ab8aa62..d3c9d93d 100644
--- a/src/pkgcore/ebuild/cpv.py
+++ b/src/pkgcore/ebuild/cpv.py
@@ -22,7 +22,7 @@ isvalid_version_re = regexp(
 
 # see https://github.com/pkgcore/pkgcore/issues/453 for why this regex 
underscores
 # PMS Category names regex is directly replicated below.
-isvalid_cat_re = regexp(r"^(?:[A-Za-z0-9_][A-Za-z0-9+_-]*)$")
+isvalid_cat_re = regexp(r"^(?:[A-Za-z0-9_][A-Za-z0-9+_.-]*)$")
 
 # empty string is fine, means a -- was encounter.
 _pkg_re = regexp(r"^[a-zA-Z0-9+_]+$")
@@ -350,11 +350,7 @@ class CPV(base.base):
         return hash(self.cpvstr)
 
     def __repr__(self):
-        return "<%s cpvstr=%s @%#8x>" % (
-            self.__class__.__name__,
-            getattr(self, "cpvstr", None),
-            id(self),
-        )
+        return f"<{self.__class__.__name__} cpvstr={getattr(self, 'cpvstr', 
None)} @{id(self):#8x}>"
 
     def __str__(self):
         return getattr(self, "cpvstr", "None")

diff --git a/tests/ebuild/test_cpv.py b/tests/ebuild/test_cpv.py
index 9b8e84be..ab85af54 100644
--- a/tests/ebuild/test_cpv.py
+++ b/tests/ebuild/test_cpv.py
@@ -30,15 +30,17 @@ class TestCPV:
         "multi--hyphen",
         "_dev",
         "_",  # yep, that's legal.
+        "cross-hppa2.0-unknown-linux-gnu",  # 
https://github.com/pkgcore/pkgcore/issues/463
     )
     bad_cats = (
         "",
+        ".reject",
+        " reject",
         "-",
         "+",
         "dev-util ",
         "multi/blah/depth",
         "multi//depth",
-        "reject.a",
     )
     good_pkgs = (
         "diffball",
@@ -83,7 +85,7 @@ class TestCPV:
 
     testing_secondary_args = False
 
-    def make_inst(self, cat, pkg, fullver=""):
+    def make_inst(self, cat: str, pkg: str, fullver: str = ""):
         if self.testing_secondary_args:
             return cpv.CPV(cat, pkg, fullver, versioned=bool(fullver))
         if fullver:
@@ -176,7 +178,7 @@ class TestCPV:
             assert c.version is None
             assert c.fullver is None
 
-    def process_ver(self, ret, cat, pkg, ver, rev):
+    def process_ver(self, ret: bool, cat: str, pkg: str, ver: str, rev: str):
         if ret:
             with pytest.raises(cpv.InvalidCPV):
                 self.make_inst(cat, pkg, f"{ver}{rev}")

Reply via email to