commit: 5ddd37d67afa38febd975cf61f46b87f42e89d3f
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Sat Oct 25 16:37:59 2025 +0000
Commit: Brian Harring <ferringb <AT> gmail <DOT> com>
CommitDate: Fri Nov 21 22:23:17 2025 +0000
URL:
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=5ddd37d6
chore: add missing __slots__ for various mappings.
These always should've been there, it's just older
code from before the slotting work. Being the underlying
classes *are* slotted, slot these.
Note: this can result in exposing bugs in code deriving
from these classes, which was setting it's own __slots__.
Effectively the __dict__ just got removed, so their class
*will* do what they intended- be slotted. If there code
didn't account for all needed slots, it'll break.
Nothing I've audited is at risk, and their code would
be buggy anyways, so this change is safe.
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
src/pkgcore/binpkg/remote.py | 2 ++
src/pkgcore/binpkg/repository.py | 1 +
src/pkgcore/config/central.py | 1 +
src/pkgcore/ebuild/misc.py | 2 +-
src/pkgcore/ebuild/portage_conf.py | 1 +
src/pkgcore/repository/prototype.py | 6 +++++-
src/pkgcore/repository/util.py | 2 ++
src/pkgcore/scripts/pclean.py | 2 ++
8 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/pkgcore/binpkg/remote.py b/src/pkgcore/binpkg/remote.py
index e93b3911..ef08b70f 100644
--- a/src/pkgcore/binpkg/remote.py
+++ b/src/pkgcore/binpkg/remote.py
@@ -36,6 +36,8 @@ class CacheEntry(StackedDict):
returns None instead. This is likely to be changed.
"""
+ __slots__ = ()
+
def pop(self, key, default=None):
try:
return self[key]
diff --git a/src/pkgcore/binpkg/repository.py b/src/pkgcore/binpkg/repository.py
index 40879955..e5ede1bf 100644
--- a/src/pkgcore/binpkg/repository.py
+++ b/src/pkgcore/binpkg/repository.py
@@ -184,6 +184,7 @@ class StackedXpakDict(DictMixin):
class StackedCache(StackedDict):
+ __slots__ = ()
__externally_mutable__ = True
def __delitem__(self, key):
diff --git a/src/pkgcore/config/central.py b/src/pkgcore/config/central.py
index 58463863..c33beaec 100644
--- a/src/pkgcore/config/central.py
+++ b/src/pkgcore/config/central.py
@@ -32,6 +32,7 @@ class _ConfigMapping(mappings.DictMixin):
any of them are remote!
"""
+ __slots__ = ("manager", "typename")
typename: str
def __init__(self, manager, typename: str) -> None:
diff --git a/src/pkgcore/ebuild/misc.py b/src/pkgcore/ebuild/misc.py
index 674e593c..25a0a7bb 100644
--- a/src/pkgcore/ebuild/misc.py
+++ b/src/pkgcore/ebuild/misc.py
@@ -141,7 +141,7 @@ def incremental_expansion_license(
class IncrementalsDict(mappings.DictMixin):
- disable_py3k_rewriting = True
+ __slots__ = ("_dict", "_incrementals")
def __init__(self, incrementals, **kwds):
self._incrementals = incrementals
diff --git a/src/pkgcore/ebuild/portage_conf.py
b/src/pkgcore/ebuild/portage_conf.py
index 84f39ce2..44286fb4 100644
--- a/src/pkgcore/ebuild/portage_conf.py
+++ b/src/pkgcore/ebuild/portage_conf.py
@@ -93,6 +93,7 @@ class ParseConfig(configparser.ConfigParser):
class PortageConfig(DictMixin):
"""Support for portage's config file layout."""
+ __slots__ = ("_config", "dir", "root", "features")
_supported_repo_types = {}
def __init__(self, location=None, profile_override=None, **kwargs):
diff --git a/src/pkgcore/repository/prototype.py
b/src/pkgcore/repository/prototype.py
index c44cb3ce..a07aa946 100644
--- a/src/pkgcore/repository/prototype.py
+++ b/src/pkgcore/repository/prototype.py
@@ -4,8 +4,8 @@ base repository template
__all__ = ("CategoryLazyFrozenSet", "PackageMapping", "VersionMapping", "tree")
-from pathlib import Path
import typing
+from pathlib import Path
from snakeoil.klass import jit_attr
from snakeoil.mappings import DictMixin, LazyValDict
@@ -42,6 +42,8 @@ class CategoryLazyFrozenSet:
class PackageMapping(DictMixin):
+ __slots__ = ("_cache", "_parent", "_pull_vals")
+
def __init__(self, parent_mapping, pull_vals):
self._cache = {}
self._parent = parent_mapping
@@ -67,6 +69,8 @@ class PackageMapping(DictMixin):
class VersionMapping(DictMixin):
+ __slots__ = ("_cache", "_parent", "_pull_vals")
+
def __init__(self, parent_mapping, pull_vals):
self._cache = {}
self._parent = parent_mapping
diff --git a/src/pkgcore/repository/util.py b/src/pkgcore/repository/util.py
index aae530f4..7b28992c 100644
--- a/src/pkgcore/repository/util.py
+++ b/src/pkgcore/repository/util.py
@@ -67,6 +67,8 @@ class RepositoryGroup(DictMixin):
combined: combined repo, if None a multiplex repo is created
"""
+ __slots__ = ("repos", "combined")
+
__externally_mutable__ = False
def __init__(self, repos=(), combined=None):
diff --git a/src/pkgcore/scripts/pclean.py b/src/pkgcore/scripts/pclean.py
index c319b9b9..3ff66cc5 100644
--- a/src/pkgcore/scripts/pclean.py
+++ b/src/pkgcore/scripts/pclean.py
@@ -257,6 +257,8 @@ def _setup_restrictions(namespace):
class _UnfilteredRepos(DictMixin):
"""Generate custom, unfiltered repos on demand."""
+ __slots__ = ("domain", "unfiltered_repos")
+
_supported_attrs = {
"pkg_masks",
"pkg_unmasks",