Skip to content

atom: fix cp/version corruption from portage's __slots__-based Atom (bug 978428)#65

Merged
gentoo-bot merged 3 commits into
gentoo:masterfrom
mattst88:fix-atom-cp-slot-978428
Jul 3, 2026
Merged

atom: fix cp/version corruption from portage's __slots__-based Atom (bug 978428)#65
gentoo-bot merged 3 commits into
gentoo:masterfrom
mattst88:fix-atom-cp-slot-978428

Conversation

@mattst88

@mattst88 mattst88 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Three fixes, bisected against the actual test failures reported in bug 978428:

  1. Stop resetting self._cp in Atom.__init__. portage already sets it correctly.
  2. Rename CPV's private version cache from _version to _bare_version to stop colliding with portage's slot.
  3. Add an explicit version property override on Atom, since new portage's version keeps the revision embedded (e.g. "2-r1") while gentoolkit's semantics keep it split out via .revision.

@thesamesam thesamesam left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI fails but looks OK once you fixed that.

@mattst88 mattst88 force-pushed the fix-atom-cp-slot-978428 branch from c27f3d9 to a664a1b Compare July 3, 2026 21:50
mattst88 added 3 commits July 3, 2026 17:53
New portage's Atom class stores _cp in __slots__ as the backing store
for its own read-only cp/category properties. Atom.__init__ was
resetting self._cp to None right after portage.dep.Atom.__init__ set
it, since gentoolkit previously needed to reinitialize CPV's private
attrs of the same name. With the new portage that reset corrupts the
shared slot instead, breaking cp/category (and anything built on
them, like intersects() and comparisons).

Old (pre-__slots__) portage never touches self._cp at all, so it's
still unset at this point and CPV.cp still needs it seeded to None to
enable its own lazy computation. Only skip the reset when portage
already populated it.

Bug: https://bugs.gentoo.org/978428
Signed-off-by: Matt Turner <mattst88@gentoo.org>
CPV._version and portage.dep.Atom's __slots__ entry _version share the
same name. Since gentoolkit's Atom subclasses both, writing to
self._version from CPV's lazy version-splitting logic overwrote
portage's real slot value instead of a separate attribute, corrupting
the raw version string portage's own properties depend on (e.g. for
wildcard atom matching in intersects()).

Rename to _bare_version, a name that can't collide with any portage
Atom slot.

Bug: https://bugs.gentoo.org/978428
Signed-off-by: Matt Turner <mattst88@gentoo.org>
New portage's Atom.version property returns the raw parsed version
string with any revision still embedded (e.g. "2-r1" for
"cat/pkg-2-r1"), unlike gentoolkit's CPV.version which is meant to
exclude the revision (kept separately in .revision). Since
portage.dep.Atom is earlier in Atom's MRO, its version property was
shadowing CPV's, breaking anything relying on the split (e.g.
fullversion, and ~ / range comparisons in intersects()).

Add an explicit override so Atom.version keeps CPV's semantics
regardless of what portage does internally.

Bug: https://bugs.gentoo.org/978428
Signed-off-by: Matt Turner <mattst88@gentoo.org>
@mattst88 mattst88 force-pushed the fix-atom-cp-slot-978428 branch from a664a1b to 5a239d8 Compare July 3, 2026 21:53
@gentoo-bot gentoo-bot merged commit 5a239d8 into gentoo:master Jul 3, 2026
9 checks passed
@mattst88 mattst88 deleted the fix-atom-cp-slot-978428 branch July 3, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants