From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7446115800F for ; Sun, 5 Feb 2023 18:16:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9AA2BE0825; Sun, 5 Feb 2023 18:16:32 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8032AE0825 for ; Sun, 5 Feb 2023 18:16:32 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 781EB33BDF0 for ; Sun, 5 Feb 2023 18:16:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EE0428A0 for ; Sun, 5 Feb 2023 18:16:29 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1675620501.95e8f3b3d418347eaa36aa3eed40de2a6e436d35.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/config/ X-VCS-Repository: proj/pkgcore/pkgcore X-VCS-Files: src/pkgcore/config/central.py X-VCS-Directories: src/pkgcore/config/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 95e8f3b3d418347eaa36aa3eed40de2a6e436d35 X-VCS-Branch: master Date: Sun, 5 Feb 2023 18:16:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 7bd8f8c8-faa1-434e-ab41-e678d27cb415 X-Archives-Hash: 9d9f2bb38571906a6c018d42874202b7 commit: 95e8f3b3d418347eaa36aa3eed40de2a6e436d35 Author: Brian Harring gmail com> AuthorDate: Tue Jan 17 09:07:19 2023 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Sun Feb 5 18:08:21 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=95e8f3b3 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 gmail.com> Signed-off-by: Arthur Zamarin gentoo.org> 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 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")