Description: The attached database contains a HSQL table with a unique index on a (case-insensitive) text field and an integer primary key. One form triggers a Basic routine on index violation. The macro analyses the error object and pops up a user-defined error message. The other form tries to do the same with Python code. However, the Python bridge complains about the error object when the following line is about to be executed: s1 = er.Message where er is ev.Source.Reason and ev.Source is an c.s.s.sdb.SQLErrorEvent Steps to Reproduce: 1. Open odb document and TBL_Basic form. 2. Add/edit some record with duplicate name or ID. 3. You get a user-defined error message. 4. Do the same with form TBL_Python Actual Results: With the Python macro you get a runtime error because Python can't swallow ev.Source.Reason A Scripting Framework error occurred while running the Python script vnd.sun.star.script:SQL_Error.py$SQLError?language=Python&location=document. Message: <class 'ImportError'>: No module named 'apso_utils' (or 'apso_utils.msgbox' is unknown) File "/opt/libreoffice7.2/program/pythonscript.py", line 1057, in getScript mod = self.provCtx.getModuleByUrl( fileUri ) File "/opt/libreoffice7.2/program/pythonscript.py", line 494, in getModuleByUrl exec(code, entry.module.__dict__) File "vnd.sun.star.tdoc:/55308760/Scripts/python/SQL_Error.py", line 3, in <module> File "/opt/libreoffice7.2/program/uno.py", line 423, in _uno_import raise uno_import_exc File "/opt/libreoffice7.2/program/uno.py", line 346, in _uno_import return _builtin_import(name, *optargs, **kwargs) Expected Results: Should work with Python as well Reproducible: Always User Profile Reset: No Additional Info: none
Created attachment 182949 [details] Database document with Basic and Python code.
@Andreas : does this require the APSO extension to be installed in order to test?
The error I see with the Python script form when changing ID from '1' to '0': com.sun.star.uno.RuntimeException: Error during invoking function SQLError in module vnd.sun.star.tdoc:/12864377288/Scripts/python/SQL_Error.py (<class 'SystemError'>: <built-in function getattr> returned a result with an error set File "/Applications/LO7412Arm.app/Contents/Resources/pythonscript.py", line 915, in invoke ret = self.func( *args ) File "vnd.sun.star.tdoc:/12864377288/Scripts/python/SQL_Error.py", line 10, in SQLError File "/Applications/LO7412Arm.app/Contents/Resources/uno.py", line 504, in _uno_struct__getattr__ return getattr(self.__dict__["value"], name) ) This is on macOS LO aarch64, M1 silicon, Monterey 12.6 (Macbook Pro).
FWIW, I get a systematic crash and recovery dialog with Version: 7.4.1.2 / LibreOffice Community Build ID: 3c58a8f3a960df8bc8fd77b461821e42c061c5f0 CPU threads: 8; OS: Mac OS X 12.6; UI render: default; VCL: osx Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR Calc: threaded when triggering the Basic script, more particularly, when clicking on "OK" of the message box. Probably worth a separate bug report.
(In reply to Alex Thurgood from comment #4) > when triggering the Basic script, more particularly, when clicking on "OK" > of the message box. Probably worth a separate bug report. Ironically, when running this against LODev daily in a lldb session, the crash doesn't occur. Remove the debug tracing, and the crash occurs systematically.
(In reply to Alex Thurgood from comment #2) > @Andreas : does this require the APSO extension to be installed in order to > test? It would require APSO if it reached the point where it shows a user defined msgbox.
(In reply to Alex Thurgood from comment #3) > The error I see with the Python script form when changing ID from '1' to '0': > > com.sun.star.uno.RuntimeException: Error during invoking function SQLError > in module vnd.sun.star.tdoc:/12864377288/Scripts/python/SQL_Error.py (<class > 'SystemError'>: <built-in function getattr> returned a result with an error > set > File "/Applications/LO7412Arm.app/Contents/Resources/pythonscript.py", > line 915, in invoke > ret = self.func( *args ) > File "vnd.sun.star.tdoc:/12864377288/Scripts/python/SQL_Error.py", line > 10, in SQLError > File "/Applications/LO7412Arm.app/Contents/Resources/uno.py", line 504, in > _uno_struct__getattr__ > return getattr(self.__dict__["value"], name) > ) I get the same in Arch Linux 64-bit, X11 Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: 0bcce236059ae68c6dcc7bce8ceaec5d39c28f1c CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: kf5 (cairo+xcb) Locale: fi-FI (fi_FI.UTF-8); UI: en-US Calc: threaded Built on 21 February 2023 with APSO installed. I don't know why this was still unconfirmed.