diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2024-02-11 19:11:24 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2024-02-11 19:11:24 -0300 |
commit | 230a70d02e13123436815635a41824f906671505 (patch) | |
tree | 478c27a66deb81a03e81c1b4bb8d241990dd5a2b /plugins/python/python.py | |
parent | 014b242df803089c34084de3d806a7c4e4dad75e (diff) | |
parent | b544ac3350e85d4cc41fe3414cbdb82d75ce5d7a (diff) |
Merge remote-tracking branch 'upstream/master' into default
Diffstat (limited to 'plugins/python/python.py')
-rw-r--r-- | plugins/python/python.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/python/python.py b/plugins/python/python.py index 7a794784..9eca7d6e 100644 --- a/plugins/python/python.py +++ b/plugins/python/python.py @@ -64,6 +64,10 @@ class Stdout: else: self.buffer += string + def flush(self): + lib.hexchat_print(lib.ph, bytes(self.buffer)) + self.buffer = bytearray() + def isatty(self): return False @@ -287,7 +291,15 @@ def _on_timer_hook(userdata): if hook.callback(hook.userdata) == True: return 1 - hook.is_unload = True # Don't unhook + try: + # Avoid calling hexchat_unhook twice if unnecessary + hook.is_unload = True + except ReferenceError: + # hook is a weak reference, it might have been destroyed by the callback + # in which case it has already been removed from hook.plugin.hooks and + # we wouldn't be able to test it with h == hook anyway. + return 0 + for h in hook.plugin.hooks: if h == hook: hook.plugin.hooks.remove(h) |