Skip to content

Commit 54a6951

Browse files
committed
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 <mattst88@gentoo.org>
1 parent 8e0b310 commit 54a6951

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pym/gentoolkit/query.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ def __init__(self, query, is_regex=False):
6262
try:
6363
atom = Atom(self.query)
6464
self.__dict__.update(atom.__dict__)
65+
# portage.dep.Atom uses __slots__, so cpv, _cp, and _version
66+
# are absent from atom.__dict__; initialize them explicitly so
67+
# CPV's lazy property accessors don't raise AttributeError.
68+
if "cpv" not in self.__dict__:
69+
self.cpv = atom.cpv
70+
for _attr in ("_version", "_cp"):
71+
if _attr not in self.__dict__:
72+
setattr(self, _attr, None)
6573
except errors.GentoolkitInvalidAtom:
6674
CPV.__init__(self, self.query)
6775
self.operator = ""

0 commit comments

Comments
 (0)