summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-02-11 01:38:58 -0800
committerZac Medico <zmedico@gentoo.org>2013-02-11 01:38:58 -0800
commitb5e88117bf4ed0aec3ab537f8f280a15b050e40c (patch)
treed6f3ed14a7d9d480227404f1156a43824ed87c61
parentCheck lib*/udev/rules.d for bug #455606. (diff)
downloadportage-b5e88117bf4ed0aec3ab537f8f280a15b050e40c.tar.gz
portage-b5e88117bf4ed0aec3ab537f8f280a15b050e40c.tar.bz2
portage-b5e88117bf4ed0aec3ab537f8f280a15b050e40c.zip
ebuild: add _reset_legacy_globals for reload
This avoids weird issues that are triggered when the module is reloaded (like having classes redefined while instances from the old classes are still around, triggering TypeError confusion).
-rwxr-xr-xbin/ebuild3
-rw-r--r--pym/portage/__init__.py31
2 files changed, 17 insertions, 17 deletions
diff --git a/bin/ebuild b/bin/ebuild
index 44b3c99d0..1ce4c9c80 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -35,7 +35,6 @@ else:
signal.signal(debug_signum, debug_signal)
-import imp
import io
import optparse
import os
@@ -157,7 +156,7 @@ if ebuild_portdir != vdb_path and \
encoding=_encodings['content'], errors='strict')
print("Appending %s to PORTDIR_OVERLAY..." % ebuild_portdir)
- imp.reload(portage)
+ portage._reset_legacy_globals()
myrepo = None
if ebuild_portdir != vdb_path:
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index a8b692c1d..bc14bae38 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -657,10 +657,17 @@ if VERSION == 'HEAD':
return VERSION
VERSION = _LazyVersion()
-if "_legacy_globals_constructed" in globals():
- # The module has been reloaded, so perform any relevant cleanup
- # and prevent memory leaks.
- if "db" in _legacy_globals_constructed:
+_legacy_global_var_names = ("archlist", "db", "features",
+ "groups", "mtimedb", "mtimedbfile", "pkglines",
+ "portdb", "profiledir", "root", "selinux_enabled",
+ "settings", "thirdpartymirrors")
+
+def _reset_legacy_globals():
+
+ global _legacy_globals_constructed
+
+ if "_legacy_globals_constructed" in globals() and \
+ "db" in _legacy_globals_constructed:
try:
db
except NameError:
@@ -684,7 +691,10 @@ if "_legacy_globals_constructed" in globals():
portdbapi.portdbapi_instances.remove(_x)
except ValueError:
pass
- del _x
+
+ _legacy_globals_constructed = set()
+ for k in _legacy_global_var_names:
+ globals()[k] = _LegacyGlobalProxy(k)
class _LegacyGlobalProxy(proxy.objectproxy.ObjectProxy):
@@ -699,16 +709,7 @@ class _LegacyGlobalProxy(proxy.objectproxy.ObjectProxy):
from portage._legacy_globals import _get_legacy_global
return _get_legacy_global(name)
-_legacy_global_var_names = ("archlist", "db", "features",
- "groups", "mtimedb", "mtimedbfile", "pkglines",
- "portdb", "profiledir", "root", "selinux_enabled",
- "settings", "thirdpartymirrors")
-
-for k in _legacy_global_var_names:
- globals()[k] = _LegacyGlobalProxy(k)
-del k
-
-_legacy_globals_constructed = set()
+_reset_legacy_globals()
def _disable_legacy_globals():
"""