Skip to content

Commit 9541ba7

Browse files
committed
Deprecate using supybot.dynamicScope without an import (#1535)
1 parent 31f4aba commit 9541ba7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/dynamicScope.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# POSSIBILITY OF SUCH DAMAGE.
2929
###
3030

31+
import logging
3132
import sys
3233

3334
class DynamicScope(object):
@@ -48,6 +49,18 @@ def __getattr__(self, name):
4849
def __setattr__(self, name, value):
4950
self._getLocals(name)[name] = value
5051

51-
(__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)['dynamic'] = DynamicScope()
52+
class _DynamicScopeBuiltinsWrapper(DynamicScope):
53+
def __getattr__(self, name):
54+
_logger = logging.getLogger('supybot')
55+
_logger.warning('Using DynamicScope without an explicit import is '
56+
'deprecated and will be removed in a future Limnoria '
57+
'version. Use instead: '
58+
'from supybot.dynamicScope import dynamic',
59+
stacklevel=2, stack_info=True)
60+
return super().__getattr__(name)
61+
62+
dynamic = DynamicScope()
63+
(__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)['dynamic'] = \
64+
_DynamicScopeBuiltinsWrapper()
5265

5366
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

0 commit comments

Comments
 (0)