From a3839b25d654d5d5215186aeca03c0ee5b84e1e3 Mon Sep 17 00:00:00 2001 From: skizzerz Date: Fri, 18 Aug 2017 17:45:47 -0500 Subject: [PATCH] Fix midgame joining in mael copy/deepcopy didn't know what to do with user objects due to custom __new__. Since __new__ returns an existing user if possible anyway, just have copy/deepcopy return the same user instance that is being copied. --- src/users.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/users.py b/src/users.py index 4818e52..5708765 100644 --- a/src/users.py +++ b/src/users.py @@ -209,6 +209,15 @@ class User(IRCContext): is_user = True + # Things break a lot if user instances aren't unique for the same data set + # __new__ already returns an existing user instance if possible, but no need + # to run through that logic if we already know what instance is desired. + def __copy__(self): + return self + + def __deepcopy__(self, memo): + return self + def __new__(cls, cli, nick, ident, host, realname, account): self = super().__new__(cls) super(__class__, self).__init__(nick, cli)