summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/repoman3
-rw-r--r--pym/_emerge/__init__.py3
-rw-r--r--pym/portage/__init__.py22
3 files changed, 19 insertions, 9 deletions
diff --git a/bin/repoman b/bin/repoman
index 09042b1e2..3f185f5af 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -38,14 +38,13 @@ except ImportError:
if not hasattr(__builtins__, "set"):
from sets import Set as set
-os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
try:
import portage
except ImportError:
from os import path as osp
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
-del os.environ["PORTAGE_LEGACY_GLOBALS"]
+portage._disable_legacy_globals()
try:
from repoman.checks import run_checks
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 78e70de71..8c30b4f01 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -31,14 +31,13 @@ import gc
import os, stat
import platform
-os.environ["PORTAGE_LEGACY_GLOBALS"] = "false"
try:
import portage
except ImportError:
from os import path as osp
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
-del os.environ["PORTAGE_LEGACY_GLOBALS"]
+portage._disable_legacy_globals()
from portage import digraph, portdbapi
from portage.const import NEWS_LIB_PATH, CACHE_PATH, PRIVATE_PATH, USER_CONFIG_PATH, GLOBAL_CONFIG_PATH
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 16760c8d4..9859e0f5e 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -7009,6 +7009,22 @@ class _MtimedbProxy(portage.util.ObjectProxy):
name = object.__getattribute__(self, '_name')
return globals()[name]
+_legacy_global_var_names = ("archlist", "db", "features",
+ "groups", "mtimedb", "mtimedbfile", "pkglines",
+ "portdb", "profiledir", "root", "selinux_enabled",
+ "settings", "thirdpartymirrors", "usedefaults")
+
+def _disable_legacy_globals():
+ """
+ This deletes the ObjectProxy instances that are used
+ for lazy initialization of legacy global variables.
+ The purpose of deleting them is to prevent new code
+ from referencing these deprecated variables.
+ """
+ global _legacy_global_var_names
+ for k in _legacy_global_var_names:
+ globals().pop(k, None)
+
# Initialization of legacy globals. No functions/classes below this point
# please! When the above functions and classes become independent of the
# below global variables, it will be possible to make the below code
@@ -7072,11 +7088,7 @@ def init_legacy_globals():
# within Portage under any circumstances.
# ========================================================================
-# WARNING!
-# The PORTAGE_LEGACY_GLOBALS environment variable is reserved for internal
-# use within Portage. External use of this variable is unsupported because
-# it is experimental and it's behavior is likely to change.
-if "PORTAGE_LEGACY_GLOBALS" not in os.environ:
+if True:
_mtimedb_initialized = False
mtimedb = _MtimedbProxy("mtimedb")