aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-03-26 18:43:57 -0400
committerRapptz <[email protected]>2017-03-26 18:43:57 -0400
commitcac84e517bb7c3a41969d37bf5eafc141277c120 (patch)
tree823d433de4cb1103ee77573dd924c64aa2f95bb9
parentRemove unnecessary shielding. (diff)
downloaddiscord.py-cac84e517bb7c3a41969d37bf5eafc141277c120.tar.xz
discord.py-cac84e517bb7c3a41969d37bf5eafc141277c120.zip
Always overwrite Emoji references in the state.
There is potential that when recreating the Emoji list in the GUILD_EMOJIS_UPDATE event would just fetch from cache and the element in cache having an out of date Guild reference. This Guild reference will be kept alive for longer than it should be. By always overwriting the Emoji reference, this problem goes away.
-rw-r--r--discord/state.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/discord/state.py b/discord/state.py
index 497fa130..72a4f01a 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -141,11 +141,8 @@ class ConnectionState:
def store_emoji(self, guild, data):
emoji_id = int(data['id'])
- try:
- return self._emojis[emoji_id]
- except KeyError:
- self._emojis[emoji_id] = emoji = Emoji(guild=guild, state=self, data=data)
- return emoji
+ self._emojis[emoji_id] = emoji = Emoji(guild=guild, state=self, data=data)
+ return emoji
@property
def guilds(self):