Description: My python-scripts which uses ScriptForge in Windows 11 don’t work anymore in version 24.8.1. When I start a Calc spreadsheet under this version I get a system error message that states "doc = CreateScriptService(‘Calc’) " is not available. I think this is a severe problem in version. In the previous versie this problem doesn't exist. Actual Results: system error message failure doc = CreateScriptService(‘Calc’) Expected Results: I cannot run my python-scripts Reproducible: Always User Profile Reset: No Additional Info: From an user I received this test witch wihich he reproduced the error: from scriptforge import CreateScriptService def testSF_CreateScriptProvider(): srv = CreateScriptService("Calc")
Created attachment 196445 [details] Libre Office faillure message
I confirm the issue in: Version: 24.8.1.2 (X86_64) / LibreOffice Community Build ID: 87fa9aec1a63e70835390b81c40bb8993f1d4ff6 CPU threads: 4; OS: Windows 10 X86_64 (10.0 build 19045); UI render: Skia/Raster; VCL: win Locale: en-US (en_US); UI: en-US Calc: threaded Also in LO 25.2 master built from source on Linux. The problem does not happen in: Version: 24.2.5.2 (X86_64) / LibreOffice Community Build ID: 420(Build:2) CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: kf5 (cairo+xcb) Locale: pt-BR (pt_BR.UTF-8); UI: en-US Ubuntu package version: 4:24.2.5-0ubuntu0.24.04.2 Calc: threaded I tested this simply using Apso Python Shell and typing the following: from scriptforge import CreateScriptService doc = CreateScriptService("Calc") Fails in 24.8, but works in 24.2. @JPL any idea what may be happening?
The issue exists as soon as the LO version is >= 24.8 whatever the operating system. I run tests in 24.2 and 24.8 with identical ScriptForge sources. The result is that everything is OK in 24.2 and nothing is OK in 24.8. ScriptForge is broken both in Python and Basic. Many other user scripts are broken as well, I presume. The issue is in fact that the error "Variable not defined" is raised on a Basic End With statement, which is VERY strange. I reproduce the issue with a already much simpler piece of code: Sub Main Dim a, b, c, d GlobalScope.BasicLibraries.loadLibrary("ScriptForge") GlobalScope.BasicLibraries.loadLibrary("XrayTool") SF_Utils._InitializeRoot(True) a = SF_Utils._GetUNOService("BrowseNodeFactory") xray a End Sub My observations so far: - it seems related with the presence of embedded With statements, what SF uses abundantly ... - The With statement has been revisited between 24.2 and 24.8: it is now possible to put a breakpoint on a With or a End With statement (also strange IMO). I will continue to search for a minimal code that causes the error to document it more precisely, if possible. I do not assign the bug to myself, as I do not consider that the ScriptForge piece of code is involved in the first place. Thanks for reporting the bug.
Thanks JPL for the analysis. So this may be related to bug 162935. @Mike, any idea if this ticket is related? I tested today with your fix for bug 162935 applied, but still I'm getting the same error reported by JPL. Running this code... Sub Main Dim a, b, c, d GlobalScope.BasicLibraries.loadLibrary("ScriptForge") SF_Utils._InitializeRoot(True) a = SF_Utils._GetUNOService("BrowseNodeFactory") End Sub ... will causa an error at the end of the With statement. Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 735ca7328e2303ff39523f75b59547bd356e33a0 CPU threads: 16; OS: Linux 6.8; UI render: default; VCL: kf5 (cairo+xcb) Locale: pt-BR (pt_BR.UTF-8); UI: en-US Calc: CL threaded
(In reply to Rafael Lima from comment #4) > @Mike, any idea if this ticket is related? It is related to bug 132064 fix, so it is similar to bug 162935, as both are regressions from that. Thank you both for the analysis! I don't know if there is a unit test suite for SF; if there is, I would appreciate, if you create a unit test for this, after the fix lands. Thanks again!
https://gerrit.libreoffice.org/c/core/+/173417
I confirm this error. When I try to run python Macros in 28.2 they don't work. When I revert to 24.2 they work. It is a Windows platform.
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/40d0e6f4c4ca31f6525b4c84924f2330a166182c tdf#162962: always create a local "Nothing" for the "WITH" variable It will be available in 25.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
(In reply to Mike Kaganski from comment #5) > I don't know if there is a unit test suite for SF; if there is, I would > appreciate, if you create a unit test for this, after the fix lands. Thanks > again! No... we still do not have Unit tests in the core repo. This is something that we need to start working on.
(In reply to HarrySpier from comment #7) HarrySpier's problem is unrelated: it is Windows 7, which is known to not support Python out of the box in version 24.8 (see release notes: https://wiki.documentfoundation.org/ReleaseNotes/24.8#Platform_Compatibility). Ref: https://ask.libreoffice.org/t/python-not-recognized-in-libreoffice-28-2/110908
Mike Kaganski committed a patch related to this issue. It has been pushed to "libreoffice-24-8": https://git.libreoffice.org/core/commit/af065575843273f242209d30f3cfda33d40974f0 tdf#162962: always create a local "Nothing" for the "WITH" variable It will be available in 24.8.2. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Created attachment 196520 [details] the failure-test on LO 24.8.2 My Scriptforge tests failed again on LO 24.8.2
(In reply to John van Mersbergen from comment #12) > My Scriptforge tests failed again on LO 24.8.2 ... which full version (from the About dialog) you didn't mention, but based on the ODT metadata, that was 10f5e3d255c094bb34155f6354b93e93289e43a0, which was from 2024-09-16, while this bug was only fixed on 2024-09-17, and the commit notification told to use the daily available in the next 24-48 hours.
Created attachment 196586 [details] Scriptforge test LO 24.8.2 Both my tests succeeded, so this bug seems to be fixed.