summaryrefslogtreecommitdiff
path: root/crocoite
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2019-03-05 11:46:27 +0100
committerLars-Dominik Braun <lars@6xq.net>2019-03-05 11:46:27 +0100
commit047c3dbc9871ce93a26057ba339efb7c53724910 (patch)
tree2aae6e2afcaee98970c568e2322cff5fd38f6baa /crocoite
parent98e668eaab64005cdccc204a787658743d3ece0f (diff)
downloadcrocoite-047c3dbc9871ce93a26057ba339efb7c53724910.tar.gz
crocoite-047c3dbc9871ce93a26057ba339efb7c53724910.tar.bz2
crocoite-047c3dbc9871ce93a26057ba339efb7c53724910.zip
Replace mutable default arguments
This fixes IRC permission checks. Previously all users who joined the channel after the bot stored their modes in the same set(). Can be detected with pylint W0102.
Diffstat (limited to 'crocoite')
-rw-r--r--crocoite/controller.py4
-rw-r--r--crocoite/irc.py14
2 files changed, 9 insertions, 9 deletions
diff --git a/crocoite/controller.py b/crocoite/controller.py
index eb8908c..788a131 100644
--- a/crocoite/controller.py
+++ b/crocoite/controller.py
@@ -108,13 +108,13 @@ class SinglePageController:
def __init__ (self, url, logger, \
service, behavior=cbehavior.available, \
- settings=defaultSettings, handler=[]):
+ settings=defaultSettings, handler=None):
self.url = url
self.service = service
self.behavior = behavior
self.settings = settings
self.logger = logger.bind (context=type (self).__name__, url=url)
- self.handler = handler
+ self.handler = handler or []
def processItem (self, item):
for h in self.handler:
diff --git a/crocoite/irc.py b/crocoite/irc.py
index 2e14537..1f06158 100644
--- a/crocoite/irc.py
+++ b/crocoite/irc.py
@@ -124,9 +124,9 @@ class User:
""" IRC user """
__slots__ = ('name', 'modes')
- def __init__ (self, name, modes=set ()):
+ def __init__ (self, name, modes=None):
self.name = name
- self.modes = modes
+ self.modes = modes or set ()
def __eq__ (self, b):
return self.name == b.name
@@ -198,9 +198,9 @@ class ArgparseBot (bottom.Client):
__slots__ = ('channels', 'nick', 'parser', 'users', '_quit')
- def __init__ (self, host, port, ssl, nick, logger, channels=[], loop=None):
+ def __init__ (self, host, port, ssl, nick, logger, channels=None, loop=None):
super().__init__ (host=host, port=port, ssl=ssl, loop=loop)
- self.channels = channels
+ self.channels = channels or []
self.nick = nick
# map channel -> nick -> user
self.users = defaultdict (dict)
@@ -374,14 +374,14 @@ def jobExists (func):
class Chromebot (ArgparseBot):
__slots__ = ('jobs', 'tempdir', 'destdir', 'processLimit', 'blacklist')
- def __init__ (self, host, port, ssl, nick, logger, channels=[],
- tempdir=tempfile.gettempdir(), destdir='.', processLimit=1,
+ def __init__ (self, host, port, ssl, nick, logger, channels=None,
+ tempdir=None, destdir='.', processLimit=1,
blacklist={}, loop=None):
super().__init__ (host=host, port=port, ssl=ssl, nick=nick,
logger=logger, channels=channels, loop=loop)
self.jobs = {}
- self.tempdir = tempdir
+ self.tempdir = tempdir or tempfile.gettempdir()
self.destdir = destdir
self.processLimit = asyncio.Semaphore (processLimit)
self.blacklist = blacklist