Skip to content

Commit

Permalink
Don't use python-reserved __name__ for private attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
numberoverzero committed Jan 2, 2016
1 parent db7b0ed commit 1d506e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions bottom/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self, getparams, *, loop):
# where event is a string, and list(func) is the list of functions
# (wrapped and decorated) that will be invoked when the given event
# is triggered.
self.__partials__ = collections.defaultdict(list)
self.__getparams__ = getparams
self._partials = collections.defaultdict(list)
self._getparams = getparams
self.loop = loop

def _add_event(self, event, func):
Expand All @@ -25,13 +25,13 @@ def _add_event(self, event, func):
up argument injection.
'''
parameters = self.__getparams__(event)
parameters = self._getparams(event)
validate_func(event, func, parameters)
self.__partials__[event].append(partial_bind(func))
self._partials[event].append(partial_bind(func))
return func

def trigger(self, event, **kwargs):
partials = self.__partials__[event]
partials = self._partials[event]
for func in partials:
self.loop.create_task(func(**kwargs))

Expand Down
2 changes: 1 addition & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_on(client):
@client.on('privmsg')
def route(nick, target, message):
pass
assert len(client.__partials__["PRIVMSG"]) == 1
assert len(client._partials["PRIVMSG"]) == 1

with pytest.raises(ValueError):
client.on("UNKNOWN_COMMAND")(route)
Expand Down

0 comments on commit 1d506e7

Please sign in to comment.