public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/config/
Date: Sun,  5 Feb 2023 18:16:29 +0000 (UTC)	[thread overview]
Message-ID: <1675620501.95e8f3b3d418347eaa36aa3eed40de2a6e436d35.arthurzam@gentoo> (raw)

commit:     95e8f3b3d418347eaa36aa3eed40de2a6e436d35
Author:     Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Jan 17 09:07:19 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> 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 <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> 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")


             reply	other threads:[~2023-02-05 18:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-05 18:16 Arthur Zamarin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-02-02 20:10 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/config/ Arthur Zamarin
2023-02-02 20:10 Arthur Zamarin
2023-01-17 20:50 Arthur Zamarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1675620501.95e8f3b3d418347eaa36aa3eed40de2a6e436d35.arthurzam@gentoo \
    --to=arthurzam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox