Commit de9169f
committed
dependencies: fix graph_reverse_depends crash on Atom.intersects
Atom.intersects() type-checks its argument since portage removed str
subtyping from Atom, so it needs a real Atom object, not a Dependencies
(a Query subclass) or a plain string.
graph_reverse_depends() called dep.intersects(self) where self is a
Dependencies object. Pass self.atom instead, but that then exposed a
second bug: gentoolkit.atom.Atom.__init__ sets self.atom to the raw atom
string it was constructed from (used by __repr__/__str__).
Query.__init__ copied that string into self.atom via __dict__.update(),
and its fallback except branch set self.atom = self.cpv (also a plain
string), so Query.atom was never actually usable as an Atom. Fix both:
restore self.atom to the real Atom object in the success path, and
construct one from self.cpv in the fallback path.
That still leaves bare package-name queries (e.g. "simdjson") crashing:
they parse as neither a valid atom nor a valid CPV, so Query.__init__
falls back further to a plain string in self.atom, which
Atom.intersects() can't type-check. Since gentoolkit's Atom can't
represent a name-only atom at all (portage.dep.Atom rejects it),
graph_reverse_depends() now passes self instead of self.atom whenever
self.atom isn't a real Atom. self already carries the .cp/.category/.name
attributes intersects() needs for its name-only comparison, and since
self.cp (unslashed) never equals dep.cp ("cat/pkg"), that comparison
always takes the early-return branch, so the attributes intersects()
doesn't check (.repo, .slot, etc.) are never touched.
Bug: https://bugs.gentoo.org/981521
Signed-off-by: Matt Turner <mattst88@gentoo.org>1 parent 58cac13 commit de9169f
2 files changed
Lines changed: 22 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
230 | 240 | | |
231 | 241 | | |
232 | 242 | | |
| |||
236 | 246 | | |
237 | 247 | | |
238 | 248 | | |
239 | | - | |
| 249 | + | |
240 | 250 | | |
241 | 251 | | |
242 | 252 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
| |||
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
79 | 89 | | |
80 | 90 | | |
81 | 91 | | |
| |||
0 commit comments