Skip to content

Commit

Permalink
Deprecate using supybot.dynamicScope without an import (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlu5 committed Aug 12, 2023
1 parent 31f4aba commit 9541ba7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/dynamicScope.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# POSSIBILITY OF SUCH DAMAGE.
###

import logging
import sys

class DynamicScope(object):
Expand All @@ -48,6 +49,18 @@ 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):
_logger = logging.getLogger('supybot')
_logger.warning('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, stack_info=True)
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:

0 comments on commit 9541ba7

Please sign in to comment.