home · contact · privacy
Ensure proper resets of dicts on connect/disconnect.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 18 Sep 2025 00:47:04 +0000 (02:47 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 18 Sep 2025 00:47:04 +0000 (02:47 +0200)
ircplom/client.py
test.txt

index 14274b65dd3b82e7222efb81809006011a718241..6b9cd1003ad6bf9df67c33dba32f7518880b8b9c 100644 (file)
@@ -571,14 +571,6 @@ class _UpdatingChannelsDict(_UpdatingDict[_UpdatingChannel]):
 
 class _UpdatingIsupportDict(_UpdatingDict[str]):
 
-    def __init__(self, **kwargs) -> None:
-        super().__init__(**kwargs)
-        self._set_defaults()
-
-    def _set_defaults(self):
-        for key, value in ISUPPORT_DEFAULTS.items():
-            self._dict[key] = value
-
     def __delitem__(self, key: str) -> None:
         if key in ISUPPORT_DEFAULTS:
             self[key] = ISUPPORT_DEFAULTS[key]
@@ -587,7 +579,8 @@ class _UpdatingIsupportDict(_UpdatingDict[str]):
 
     def clear(self) -> None:
         super().clear()
-        self._set_defaults()
+        for key, value in ISUPPORT_DEFAULTS.items():
+            self[key] = value
 
 
 class _ClientDb(_Clearable, _UpdatingAttrsMixin, SharedClientDbFields):
@@ -762,6 +755,7 @@ class Client(ABC, ClientQueueMixin):
         self.client_id = conn_setup.hostname
         super().__init__(client_id=self.client_id, **kwargs)
         self.db = _ClientDb(on_update=self._on_update)
+        self.db.clear()
         self.caps = _CapsManager(self.send, self.db.caps)
         for k in conn_setup.__annotations__:
             setattr(self.db, k, getattr(conn_setup, k))
index 7f52a0209972502baa039044d212eec4054cb080..287dde1f03b33d915e16d9218b0e09f2e4993a3f 100644 (file)
--- a/test.txt
+++ b/test.txt
 # ETC.
 
 > /connect foo.bar.baz foo:bar baz
+1,2 $ isupport cleared
+1,2 $ isupport:CHANTYPES set to: [#&]
+1,2 $ isupport:PREFIX set to: [(ov)@+]
 1,2 $ caps cleared
+1,2 $ users cleared
+1,2 $ channels cleared
 1,2 $ hostname set to: [foo.bar.baz]
 1,2 $ port set to: [-1]
 1,2 $ nick_wanted set to: [foo]
@@ -53,8 +58,6 @@
 
 1,2 $ connection_state set to: [connecting]
 
-1,2 $ channels cleared
-1,2 $ users cleared
 1,2 $ ?!?@? renames ?
 1,2 $ users:me:user set to: [plom]
 1,2 $ connection_state set to: [connected]
@@ -71,8 +74,6 @@
 1,2 $$$ *** Found your hostname (baz.bar.foo)
 
 2 < :*.?.net CAP * LS : foo bar sasl=PLAIN,EXTERNAL baz
-1,2 $ isupport:CHANTYPES set to: [#&]
-1,2 $ isupport:PREFIX set to: [(ov)@+]
 2 > CAP REQ :sasl
 2 > CAP :LIST
 
 1,2,3,4 $ connection_state set to: [Closing link: (plom@baz.bar.foo) [Quit: ircplom says bye]]
 1,2,3,4 $ connection_state set to: []
 1,2 $ isupport cleared
+1,2 $ isupport:CHANTYPES set to: [#&]
+1,2 $ isupport:PREFIX set to: [(ov)@+]
 1,2 $ motd set to:
 1,2 $ sasl_account set to: []
 1,2 $ sasl_auth_state set to: []