Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate using supybot.dynamicScope without an import #1544

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
5 changes: 2 additions & 3 deletions src/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ def exception(self, *args):
# The traceback should be sufficient if we want it.
# self.error('Exception string: %s', eStrId)

def _log(self, level, msg, args, exc_info=None, extra=None):
def _log(self, level, msg, args, **kwargs):
msg = format(msg, *args)
logging.Logger._log(self, level, msg, (), exc_info=exc_info,
extra=extra)
logging.Logger._log(self, level, msg, (), **kwargs)


class StdoutStreamHandler(logging.StreamHandler):
Expand Down