From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/
Date: Mon, 11 Feb 2013 09:39:12 +0000 (UTC) [thread overview]
Message-ID: <1360575538.b5e88117bf4ed0aec3ab537f8f280a15b050e40c.zmedico@gentoo> (raw)
commit: b5e88117bf4ed0aec3ab537f8f280a15b050e40c
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 11 09:38:58 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 11 09:38:58 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b5e88117
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).
---
bin/ebuild | 3 +--
pym/portage/__init__.py | 31 ++++++++++++++++---------------
2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/bin/ebuild b/bin/ebuild
index 44b3c99..1ce4c9c 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 a8b692c..bc14bae 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():
"""
next reply other threads:[~2013-02-11 9:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-11 9:39 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-11-17 17:43 [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/ Zac Medico
2013-11-29 23:24 Mike Frysinger
2013-06-25 7:48 Zac Medico
2013-06-23 22:57 Zac Medico
2013-06-23 22:40 Zac Medico
2013-01-19 5:16 Zac Medico
2013-01-19 5:00 Zac Medico
2013-01-19 3:23 Zac Medico
2013-01-19 3:23 Zac Medico
2013-01-19 2:27 Zac Medico
2013-01-19 1:53 Zac Medico
2012-10-18 0:05 Zac Medico
2012-03-17 16:44 Zac Medico
2012-03-11 1:40 Mike Frysinger
2011-12-08 7:26 Zac Medico
2011-06-17 22:35 Zac Medico
2011-06-04 1:39 Zac Medico
2011-02-20 0:00 Zac Medico
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=1360575538.b5e88117bf4ed0aec3ab537f8f280a15b050e40c.zmedico@gentoo \
--to=zmedico@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