From 9c86f1898265508adca0a90e165213c46211abdb Mon Sep 17 00:00:00 2001 From: deepend Date: Wed, 25 Feb 2026 01:58:19 -0700 Subject: [PATCH] Cleaned up unneeded inline comments in plugins/python/python.py while keeping runtime behavior unchanged (comment-only cleanup around version declaration, compile helpers, wordlist/timer handling, and autoload path handling). --- plugins/python/python.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/plugins/python/python.py b/plugins/python/python.py index 0ff20d8f..ec90f3a8 100644 --- a/plugins/python/python.py +++ b/plugins/python/python.py @@ -19,7 +19,7 @@ else: if not hasattr(sys, 'argv'): sys.argv = [''] -VERSION = b'2.18.0~pre2' # Sync with zoitechat.__version__ +VERSION = b'2.18.0~pre2' PLUGIN_NAME = ffi.new('char[]', b'Python') PLUGIN_DESC = ffi.new('char[]', b'Python %d.%d scripting interface' % (sys.version_info[0], sys.version_info[1])) PLUGIN_VERSION = ffi.new('char[]', VERSION) @@ -105,8 +105,6 @@ if sys.version_info[0] == 2: return compile(string, '', 'eval', dont_inherit=True) except SyntaxError: - # For some reason `print` is invalid for eval - # This will hide any return value though return compile(string, '', 'exec', dont_inherit=True) else: def compile_file(data, filename): @@ -114,7 +112,6 @@ else: def compile_line(string): - # newline appended to solve unexpected EOF issues return compile(string + '\n', '', 'single', optimize=2, dont_inherit=True) @@ -199,8 +196,6 @@ else: return string.decode() -# There can be empty entries between non-empty ones so find the actual last value - def _cstr(ptr): """Safely convert a C char* (possibly NULL) to bytes.""" if ptr == ffi.NULL: @@ -211,7 +206,6 @@ def _cstr(ptr): return b'' def wordlist_len(words): - # ZoiteChat passes a fixed-size array (typically 32) where unused entries may be NULL. for i in range(31, 0, -1): if _cstr(words[i]): return i @@ -298,12 +292,8 @@ def _on_timer_hook(userdata): return 1 try: - # Avoid calling zoitechat_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: @@ -337,11 +327,9 @@ def _on_say_command(word, word_eol, userdata): if not python: return 1 - # Don’t let exceptions here swallow core commands or wedge the UI. try: exec_in_interp(python) except Exception: - # Best effort: surface the traceback in the python tab. exc = traceback.format_exc().encode('utf-8', errors='replace') lib.zoitechat_print(lib.ph, exc) return 1 @@ -396,11 +384,10 @@ def autoload(): configdir = __decode(_cstr(lib.zoitechat_get_info(lib.ph, b'configdir'))) addondir = os.path.join(configdir, 'addons') try: - with change_cwd(addondir): # Maintaining old behavior + with change_cwd(addondir): for f in os.listdir(addondir): if f.endswith('.py'): log('Autoloading', f) - # TODO: Set cwd load_filename(os.path.join(addondir, f)) except FileNotFoundError as e: