diff --git a/plugins/Aka/plugin.py b/plugins/Aka/plugin.py index 2c8ee9caa..1e4db5f86 100644 --- a/plugins/Aka/plugin.py +++ b/plugins/Aka/plugin.py @@ -42,6 +42,7 @@ import supybot.ircutils as ircutils import supybot.callbacks as callbacks import supybot.httpserver as httpserver +from supybot.dynamicScope import dynamic from supybot.i18n import PluginInternationalization _ = PluginInternationalization('Aka') diff --git a/plugins/Factoids/plugin.py b/plugins/Factoids/plugin.py index cfa20d49b..55d078412 100644 --- a/plugins/Factoids/plugin.py +++ b/plugins/Factoids/plugin.py @@ -43,6 +43,7 @@ import supybot.ircutils as ircutils import supybot.callbacks as callbacks import supybot.httpserver as httpserver +from supybot.dynamicScope import dynamic from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Factoids') diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index b7c6006f4..abd5f6e0c 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -41,6 +41,7 @@ import supybot.ircmsgs as ircmsgs import supybot.ircutils as ircutils import supybot.callbacks as callbacks +from supybot.dynamicScope import dynamic from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Google') diff --git a/plugins/Relay/plugin.py b/plugins/Relay/plugin.py index a520bb725..b3350dfc2 100644 --- a/plugins/Relay/plugin.py +++ b/plugins/Relay/plugin.py @@ -41,6 +41,7 @@ import supybot.ircutils as ircutils import supybot.callbacks as callbacks from supybot.utils.structures import MultiSet, TimeoutQueue +from supybot.dynamicScope import dynamic from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Relay') diff --git a/plugins/Success/plugin.py b/plugins/Success/plugin.py index 89e30a0c0..69097dcff 100644 --- a/plugins/Success/plugin.py +++ b/plugins/Success/plugin.py @@ -32,6 +32,7 @@ from supybot.commands import * import supybot.plugins as plugins import supybot.ircutils as ircutils +from supybot.dynamicScope import dynamic from supybot.i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization('Success') diff --git a/src/callbacks.py b/src/callbacks.py index 0844cca8e..a9681fa4b 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -43,6 +43,7 @@ import inspect import warnings +from .dynamicScope import dynamic from . import (conf, ircdb, irclib, ircmsgs, ircutils, log, registry, utils, world) from .utils import minisix diff --git a/src/commands.py b/src/commands.py index f93e7ce47..7b64aa813 100644 --- a/src/commands.py +++ b/src/commands.py @@ -46,6 +46,7 @@ from . import callbacks, conf, ircdb, ircmsgs, ircutils, log, \ utils, world +from .dynamicScope import dynamic from .utils import minisix from .i18n import PluginInternationalization, internationalizeDocstring _ = PluginInternationalization() diff --git a/src/conf.py b/src/conf.py index 16c554451..01536e951 100644 --- a/src/conf.py +++ b/src/conf.py @@ -39,6 +39,7 @@ from .utils import minisix from .utils.net import isSocketAddress from .version import version +from .dynamicScope import dynamic from .i18n import PluginInternationalization _ = PluginInternationalization() if minisix.PY2: diff --git a/src/dynamicScope.py b/src/dynamicScope.py index 40682a6e2..910c9e69c 100644 --- a/src/dynamicScope.py +++ b/src/dynamicScope.py @@ -29,6 +29,7 @@ ### import sys +import warnings class DynamicScope(object): def _getLocals(self, name): @@ -48,6 +49,17 @@ def __getattr__(self, name): def __setattr__(self, name, value): self._getLocals(name)[name] = value -(__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)['dynamic'] = DynamicScope() +class _DynamicScopeBuiltinsWrapper(DynamicScope): + def __getattr__(self, name): + warnings.warn('Using DynamicScope without an explicit import is ' + 'deprecated and will be removed in a future Limnoria ' + 'version. Use instead: ' + 'from supybot.dynamicScope import dynamic', + stacklevel=2) + return super().__getattr__(name) + +dynamic = DynamicScope() +(__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)['dynamic'] = \ + _DynamicScopeBuiltinsWrapper() # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/test/test_dynamicScope.py b/test/test_dynamicScope.py index fe9980e09..ae461bb7c 100644 --- a/test/test_dynamicScope.py +++ b/test/test_dynamicScope.py @@ -29,6 +29,7 @@ ### from supybot.test import * +from supybot.dynamicScope import dynamic class TestDynamic(SupyTestCase): def test(self):