From 95e8f3b3d418347eaa36aa3eed40de2a6e436d35 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Tue, 17 Jan 2023 01:07:19 -0800 Subject: 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 Signed-off-by: Arthur Zamarin --- src/pkgcore/config/central.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pkgcore/config/central.py b/src/pkgcore/config/central.py index 0cd2f392..12e0ce13 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") -- cgit v1.2.3-65-gdbad