From 847e5a14d6d7991682c3add853f7b3cc32f935df Mon Sep 17 00:00:00 2001 From: Celelibi Date: Mon, 3 Apr 2023 05:22:12 +0200 Subject: python: add flush() to Stdout Python sometime calls flush() on sys.stdout or sys.stderr. In particular, it might do so when an exception is raised. This fixes the second error message that was generated in such cases. Signed-off-by: Celelibi --- plugins/python/python.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugins/python') diff --git a/plugins/python/python.py b/plugins/python/python.py index 7a794784..07900eb2 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 -- cgit 1.4.1 From 5cbd2524dcedb995fc98403d1d73a3400e2cb935 Mon Sep 17 00:00:00 2001 From: Celelibi Date: Mon, 3 Apr 2023 05:25:47 +0200 Subject: python: fix for timers that unhook themselves The python plugin use weak references for hooks, which might let a necessary object disappear if the callback of a timer hook unhooks itself. Signed-off-by: Celelibi --- plugins/python/python.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'plugins/python') diff --git a/plugins/python/python.py b/plugins/python/python.py index 07900eb2..9eca7d6e 100644 --- a/plugins/python/python.py +++ b/plugins/python/python.py @@ -291,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) -- cgit 1.4.1 From a1f154cd5ee63ec6b9ac154b8dc6d5a5d97c2c28 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Fri, 3 Nov 2023 10:58:56 -0500 Subject: win32: Remove Python 2 support --- .github/workflows/windows-build.yml | 3 -- plugins/python/python2.vcxproj | 65 ---------------------------------- plugins/python/python2.vcxproj.filters | 23 ------------ src/common/plugin.c | 1 - win32/copy/copy.vcxproj | 1 - win32/hexchat.props | 4 --- win32/hexchat.sln | 11 ------ win32/installer/hexchat.iss.tt | 16 ++------- 8 files changed, 3 insertions(+), 121 deletions(-) delete mode 100644 plugins/python/python2.vcxproj delete mode 100644 plugins/python/python2.vcxproj.filters (limited to 'plugins/python') diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 4554f2a9..18aca7ca 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -40,13 +40,10 @@ jobs: Invoke-WebRequest https://dl.hexchat.net/misc/perl/perl-5.20.0-${{ matrix.arch }}.7z -OutFile deps\perl-${{ matrix.arch }}.7z & 7z.exe x deps\perl-${{ matrix.arch }}.7z -oC:\gtk-build\perl-5.20\${{ matrix.platform }} - New-Item -Path "c:\gtk-build" -Name "python-2.7" -ItemType "Directory" New-Item -Path "c:\gtk-build" -Name "python-3.8" -ItemType "Directory" - New-Item -Path "c:\gtk-build\python-2.7" -Name "${{ matrix.platform }}" -ItemType "SymbolicLink" -Value "C:/hostedtoolcache/windows/Python/2.7.18/${{ matrix.arch }}" New-Item -Path "c:\gtk-build\python-3.8" -Name "${{ matrix.platform }}" -ItemType "SymbolicLink" -Value "C:/hostedtoolcache/windows/Python/3.8.10/${{ matrix.arch }}" C:/hostedtoolcache/windows/Python/3.8.10/${{ matrix.arch }}/python.exe -m pip install cffi - C:/hostedtoolcache/windows/Python/2.7.18/${{ matrix.arch }}/python.exe -m pip install -qq cffi shell: powershell - name: Build diff --git a/plugins/python/python2.vcxproj b/plugins/python/python2.vcxproj deleted file mode 100644 index 42895ce4..00000000 --- a/plugins/python/python2.vcxproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - v142 - DynamicLibrary - - - - Release - Win32 - - - Release - x64 - - - - {19C52A0A-A790-409E-A28A-9745FF990F5C} - Win32Proj - python2 - - - - - - - $(Python2Output) - $(HexChatRel)plugins\ - - - - WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions) - $(Glib);$(Python2Path)\include;..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories) - - - python.def - "$(Python2Lib).lib";$(DepLibs);%(AdditionalDependencies) - $(DepsRoot)\lib;$(Python2Path)\libs;%(AdditionalLibraryDirectories) - - - "$(Python3Path)\python.exe" generate_plugin.py ..\..\src\common\hexchat-plugin.h python.py "$(IntDir)python.c" - - - - - WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;PYTHON_EXPORTS;$(OwnFlags);%(PreprocessorDefinitions) - $(Glib);$(Python2Path)\include;..\..\src\common;$(HexChatLib);%(AdditionalIncludeDirectories) - - - python.def - "$(Python2Lib).lib";$(DepLibs);%(AdditionalDependencies) - $(DepsRoot)\lib;$(Python2Path)\libs;%(AdditionalLibraryDirectories) - - - "$(Python3Path)\python.exe" generate_plugin.py ..\..\src\common\hexchat-plugin.h python.py "$(IntDir)python.c" - - - - - - - - - - diff --git a/plugins/python/python2.vcxproj.filters b/plugins/python/python2.vcxproj.filters deleted file mode 100644 index d56e53b6..00000000 --- a/plugins/python/python2.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Resource Files - - - - - Source Files - - - \ No newline at end of file diff --git a/src/common/plugin.c b/src/common/plugin.c index 40e55bbf..536f376d 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -491,7 +491,6 @@ plugin_auto_load (session *sess) for_files (lib_dir, "hcfishlim.dll", plugin_auto_load_cb); for_files(lib_dir, "hclua.dll", plugin_auto_load_cb); for_files (lib_dir, "hcperl.dll", plugin_auto_load_cb); - for_files (lib_dir, "hcpython2.dll", plugin_auto_load_cb); for_files (lib_dir, "hcpython3.dll", plugin_auto_load_cb); for_files (lib_dir, "hcupd.dll", plugin_auto_load_cb); for_files (lib_dir, "hcwinamp.dll", plugin_auto_load_cb); diff --git a/win32/copy/copy.vcxproj b/win32/copy/copy.vcxproj index 2fc7437b..cb3ea1cf 100644 --- a/win32/copy/copy.vcxproj +++ b/win32/copy/copy.vcxproj @@ -65,7 +65,6 @@ - diff --git a/win32/hexchat.props b/win32/hexchat.props index 5d81b2dc..d6c2bf1a 100644 --- a/win32/hexchat.props +++ b/win32/hexchat.props @@ -7,7 +7,6 @@ c:\gtk-build\gtk c:\gtk-build\gendef c:\gtk-build\perl-5.20 - c:\gtk-build\python-2.7 c:\gtk-build\python-3.8 c:\gtk-build\WinSparkle @@ -22,9 +21,6 @@ $(YourWinSparklePath)\$(PlatformName) $(YourPerlPath)\$(PlatformName) perl520 - $(YourPython2Path)\$(PlatformName) - python27 - hcpython2 $(YourPython3Path)\$(PlatformName) python38 hcpython3 diff --git a/win32/hexchat.sln b/win32/hexchat.sln index 8759c59b..57476b02 100644 --- a/win32/hexchat.sln +++ b/win32/hexchat.sln @@ -21,11 +21,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{5611 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripting", "scripting", "{D237DA6B-BD5F-46C0-8BEA-50E9A1340240}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python2", "..\plugins\python\python2.vcxproj", "{19C52A0A-A790-409E-A28A-9745FF990F5C}" - ProjectSection(ProjectDependencies) = postProject - {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checksum", "..\plugins\checksum\checksum.vcxproj", "{5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}" ProjectSection(ProjectDependencies) = postProject {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} @@ -72,7 +67,6 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\installer.vcxproj", "{5A0F4962-E670-4DA2-9E45-52CC47F26E2F}" ProjectSection(ProjectDependencies) = postProject {C2321A03-0BA7-45B3-8740-ABD82B36B0BF} = {C2321A03-0BA7-45B3-8740-ABD82B36B0BF} - {19C52A0A-A790-409E-A28A-9745FF990F5C} = {19C52A0A-A790-409E-A28A-9745FF990F5C} {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A} = {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A} {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} = {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} {4C0F3940-2EEE-4646-82F7-6CE75B9A72F4} = {4C0F3940-2EEE-4646-82F7-6CE75B9A72F4} @@ -134,10 +128,6 @@ Global {E93E1255-95D1-4B08-8FDF-B53CC6A21280}.Release|Win32.Build.0 = Release|Win32 {E93E1255-95D1-4B08-8FDF-B53CC6A21280}.Release|x64.ActiveCfg = Release|x64 {E93E1255-95D1-4B08-8FDF-B53CC6A21280}.Release|x64.Build.0 = Release|x64 - {19C52A0A-A790-409E-A28A-9745FF990F5C}.Release|Win32.ActiveCfg = Release|Win32 - {19C52A0A-A790-409E-A28A-9745FF990F5C}.Release|Win32.Build.0 = Release|Win32 - {19C52A0A-A790-409E-A28A-9745FF990F5C}.Release|x64.ActiveCfg = Release|x64 - {19C52A0A-A790-409E-A28A-9745FF990F5C}.Release|x64.Build.0 = Release|x64 {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}.Release|Win32.ActiveCfg = Release|Win32 {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}.Release|Win32.Build.0 = Release|Win32 {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}.Release|x64.ActiveCfg = Release|x64 @@ -206,7 +196,6 @@ Global {87554B59-006C-4D94-9714-897B27067BA3} = {AAACEB12-9475-410E-AF5A-FDFF907E9043} {E4BDB4C8-2335-415A-ACEE-BA88B19BFE82} = {AAACEB12-9475-410E-AF5A-FDFF907E9043} {E93E1255-95D1-4B08-8FDF-B53CC6A21280} = {AAACEB12-9475-410E-AF5A-FDFF907E9043} - {19C52A0A-A790-409E-A28A-9745FF990F5C} = {D237DA6B-BD5F-46C0-8BEA-50E9A1340240} {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} {3C4F42FC-292A-420B-B63D-C03DFBDD8E4E} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} diff --git a/win32/installer/hexchat.iss.tt b/win32/installer/hexchat.iss.tt index b03e2212..1b7c3209 100644 --- a/win32/installer/hexchat.iss.tt +++ b/win32/installer/hexchat.iss.tt @@ -75,9 +75,7 @@ Name: "plugins\winamp"; Description: "Winamp"; Types: custom; Flags: disablenoun Name: "langs"; Description: "Language Interfaces"; Types: custom; Flags: disablenouninstallwarning Name: "langs\lua"; Description: "Lua"; Types: normal custom; Flags: disablenouninstallwarning Name: "langs\perl"; Description: "Perl (requires Perl 5.20)"; Types: custom; Flags: disablenouninstallwarning -Name: "langs\python"; Description: "Python Interface"; Types: custom; Flags: disablenouninstallwarning -Name: "langs\python\python2"; Description: "Python (requires Python 2.7)"; Types: custom; Flags: disablenouninstallwarning exclusive -Name: "langs\python\python3"; Description: "Python (requires Python 3.8)"; Types: custom; Flags: disablenouninstallwarning exclusive +Name: "langs\python"; Description: "Python (requires Python 3.8)"; Types: custom; Flags: disablenouninstallwarning [Tasks] Name: portable; Description: "Yes"; GroupDescription: "Portable Mode: Stores configuration files within install directory for portable drives."; Flags: unchecked @@ -188,11 +186,8 @@ Source: "plugins\hcperl.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Co Source: "python\*.py"; DestDir: "{app}\python"; Flags: ignoreversion; Components: langs\python -Source: "plugins\hcpython2.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: langs\python\python2 -Source: "_cffi_backend.pyd"; DestDir: "{app}"; Flags: ignoreversion; Components: langs\python\python2 - -Source: "plugins\hcpython3.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: langs\python\python3 -Source: "_cffi_backend.cp3*.pyd"; DestDir: "{app}"; Flags: ignoreversion; Components: langs\python\python3 +Source: "plugins\hcpython3.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: langs\python +Source: "_cffi_backend.cp3*.pyd"; DestDir: "{app}"; Flags: ignoreversion; Components: langs\python Source: "hexchat.exe"; DestDir: "{app}"; Flags: ignoreversion; Components: libs Source: "hexchat-text.exe"; DestDir: "{app}"; Flags: ignoreversion; Components: xctext @@ -303,13 +298,11 @@ begin REDIST := 'https://dl.hexchat.net/misc/vcredist_2015_x64.exe'; REDIST_2013 := 'https://dl.hexchat.net/misc/vcredist_2013_x64.exe'; PERL := 'https://dl.hexchat.net/misc/perl/Perl%205.20.0%20x64.msi'; - PY2 := 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi'; PY3 := 'https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe'; #else REDIST := 'https://dl.hexchat.net/misc/vcredist_2015_x86.exe'; REDIST_2013 := 'https://dl.hexchat.net/misc/vcredist_2013_x86.exe'; PERL := 'https://dl.hexchat.net/misc/perl/Perl%205.20.0%20x86.msi'; - PY2 := 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.msi'; PY3 := 'https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe'; #endif DOTNET := 'https://dl.hexchat.net/misc/dotnet_40.exe'; @@ -334,9 +327,6 @@ begin idpAddFile(PERL, ExpandConstant('{tmp}\perl.msi')) end; - if IsComponentSelected('langs\python\python2') and not CheckDLL('python27.dll') then - idpAddFile(PY2, ExpandConstant('{tmp}\python.msi')); - if IsComponentSelected('langs\python\python3') and not CheckDLL('python38.dll') then idpAddFile(PY3, ExpandConstant('{tmp}\python.exe')); end; -- cgit 1.4.1