atom: fix cp/version corruption from portage's __slots__-based Atom (bug 978428)#65
Merged
Merged
Conversation
thesamesam
reviewed
Jul 3, 2026
thesamesam
left a comment
Member
There was a problem hiding this comment.
CI fails but looks OK once you fixed that.
c27f3d9 to
a664a1b
Compare
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>
a664a1b to
5a239d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three fixes, bisected against the actual test failures reported in bug 978428:
self._cpinAtom.__init__. portage already sets it correctly._versionto_bare_versionto stop colliding with portage's slot.Atom, since new portage's version keeps the revision embedded (e.g. "2-r1") while gentoolkit's semantics keep it split out via.revision.