From: Zac Medico Date: Sun, 18 Mar 2007 00:25:43 +0000 (-0000) Subject: Use locals() instead of setattr to insert generated functions into the current module... X-Git-Tag: v2.2_pre1~1564 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=393ed1e409b2f295a47f133ce4d2d920fc15770a;p=portage.git Use locals() instead of setattr to insert generated functions into the current module. Thanks to Brian Harring for the suggestion. svn path=/main/trunk/; revision=6241 --- diff --git a/pym/portage/output.py b/pym/portage/output.py index 0b58c81b6..386d4c8e5 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -235,7 +235,7 @@ def create_color_func(color_key): return derived_func for c in compat_functions_colors: - setattr(sys.modules[__name__], c, create_color_func(c)) + locals()[c] = create_color_func(c) class EOutput: """ diff --git a/pym/portage/tests/bin/setup_env.py b/pym/portage/tests/bin/setup_env.py index e0a89f1e2..a69a19ec6 100644 --- a/pym/portage/tests/bin/setup_env.py +++ b/pym/portage/tests/bin/setup_env.py @@ -66,4 +66,4 @@ for bin in os.listdir(bindir): bin.startswith("new") or \ bin.startswith("prep") or \ bin in ["ecompress","ecompressdir","fowners","fperms"]: - setattr(sys.modules[__name__], bin, create_portage_wrapper(bin)) + locals()[bin] = create_portage_wrapper(bin)