From 54a6951064607bd33fc69f24598d3457b6bdb96a Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 26 Jun 2026 21:26:28 -0400 Subject: [PATCH] query: fix AttributeError when query includes category portage.dep.Atom uses __slots__, so cpv, _cp, and _version are absent from atom.__dict__; copying it into Query left those attrs unset. CPV's lazy property accessors then raised AttributeError (e.g. "equery f app-shells/bash"). Signed-off-by: Matt Turner --- pym/gentoolkit/query.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pym/gentoolkit/query.py b/pym/gentoolkit/query.py index 3fa44637..c09438f4 100644 --- a/pym/gentoolkit/query.py +++ b/pym/gentoolkit/query.py @@ -62,6 +62,14 @@ def __init__(self, query, is_regex=False): try: atom = Atom(self.query) self.__dict__.update(atom.__dict__) + # portage.dep.Atom uses __slots__, so cpv, _cp, and _version + # are absent from atom.__dict__; initialize them explicitly so + # CPV's lazy property accessors don't raise AttributeError. + if "cpv" not in self.__dict__: + self.cpv = atom.cpv + for _attr in ("_version", "_cp"): + if _attr not in self.__dict__: + setattr(self, _attr, None) except errors.GentoolkitInvalidAtom: CPV.__init__(self, self.query) self.operator = ""