commit:     e5f973644da3279444839d79388e59c7b5d55942
Author:     Jannik Glückert <jannik.glueckert <AT> gmail <DOT> com>
AuthorDate: Sat Jun 14 11:44:56 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 20 17:31:51 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e5f97364

portage.dep.Atom: do not match trailing newline

Python regex is special in that the meaning of $ and \Z is reversed
compared to most other dialects.
In python, $ is "end of input, optionally preceded by \n".

Signed-off-by: Jannik Glückert <jannik.glueckert <AT> gmail.com>
Part-of: https://github.com/gentoo/portage/pull/1445
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/dep/__init__.py        | 4 ++--
 lib/portage/tests/dep/test_atom.py | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/portage/dep/__init__.py b/lib/portage/dep/__init__.py
index a4a5bf26bd..f8a238cd30 100644
--- a/lib/portage/dep/__init__.py
+++ b/lib/portage/dep/__init__.py
@@ -143,7 +143,7 @@ def _get_atom_re(eapi_attrs: portage.eapi._eapi_attrs) -> 
re.Pattern:
         + _repo
         + ")("
         + _use
-        + ")?$",
+        + ")?\\Z",
         re.VERBOSE | re.UNICODE,
     )
     return _atom_re
@@ -178,7 +178,7 @@ def _get_atom_wildcard_re(eapi_attrs):
         + _repo_separator
         + r"(?P<repo>"
         + _repo_name
-        + r"))?$",
+        + r"))?\Z",
         re.UNICODE,
     )
     return _atom_wildcard_re

diff --git a/lib/portage/tests/dep/test_atom.py 
b/lib/portage/tests/dep/test_atom.py
index 9cdc14cf56..3cc30b1dae 100644
--- a/lib/portage/tests/dep/test_atom.py
+++ b/lib/portage/tests/dep/test_atom.py
@@ -152,6 +152,7 @@ class TestAtom(TestCase):
 
         tests_xfail = (
             (Atom("sys-apps/portage"), False, False),
+            ("cat/pkg\n", False, False),
             ("+cat/pkg", False, False),
             ("-cat/pkg", False, False),
             (".cat/pkg", False, False),

Reply via email to