summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2023-01-17 01:07:19 -0800
committerArthur Zamarin <arthurzam@gentoo.org>2023-02-05 20:08:21 +0200
commit95e8f3b3d418347eaa36aa3eed40de2a6e436d35 (patch)
treec7de75d09f117091b920fae0579245018f5c63fc
parentrefactor(config): remove prepend/append incremental return signature fully. (diff)
downloadpkgcore-95e8f3b3d418347eaa36aa3eed40de2a6e436d35.tar.gz
pkgcore-95e8f3b3d418347eaa36aa3eed40de2a6e436d35.tar.bz2
pkgcore-95e8f3b3d418347eaa36aa3eed40de2a6e436d35.zip
fix(config): Add deprecation warnings for very old config shims
The context of this is fa90aff05306fb4935604e64645f2d1d2049233e; the original 'central' manager exposed objecst in the same attr namespace as it's own internals. Whilst no conflicts occured, it was possible, so the configuration objects were moved to .objects to remove the potential. A compatibility shim was added (CompatConfigManager), but no warnings were added at the time due to presumably the module not existing. Either way, it exists, thus add a warning. There are multiple users in pkgcore's code (fixed in followup commit). Pkgcheck and pkgdev are clean, but it may be wise to wait a release or two before removing the compatibility shim. It's been in place 11 years, not like it's going to kill us to wait another month... Signed-off-by: Brian Harring <ferringb@gmail.com> Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/pkgcore/config/central.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pkgcore/config/central.py b/src/pkgcore/config/central.py
index 0cd2f392e..12e0ce13b 100644
--- a/src/pkgcore/config/central.py
+++ b/src/pkgcore/config/central.py
@@ -9,6 +9,7 @@ __all__ = (
)
import typing
+import warnings
import weakref
from collections import defaultdict, deque, namedtuple
@@ -255,6 +256,12 @@ class _ConfigObjMap:
class CompatConfigManager:
+ """This is a compatibility hack to alias attribute access to the new location
+
+ See commit fa90aff05306fb4935604e64645f2d1d2049233e for when this was introduced.
+
+ This should be removed once consumers are converted in their access."""
+
def __init__(self, manager) -> None:
self._manager = manager
@@ -264,6 +271,10 @@ class CompatConfigManager:
obj = getattr(self._manager, attr, klass.sentinel)
if obj is klass.sentinel:
obj = getattr(self._manager.objects, attr)
+ warnings.warn(
+ f"Access to central objects must be done via '.objects.{attr}' rather than '.{attr}'",
+ stacklevel=2,
+ )
return obj
__dir__ = klass.DirProxy("_manager")