Files
odfstudio/pyuno
Neil Roberts cff7386f71 testofficehelper: Don’t assert the context is true after terminating
Once XDesktop.terminate is called, there is a race condition where if
the termination completes before the truthiness of the context is
checked then it will end up checking on a disposed object and the test
will fail. The check for truthiness ends up calling __len__ on the UNO
wrapper which tries to query some interfaces on the object. This might
be the cause of some failures on Jenkins. I can replicate it if I put a
short sleep after calling terminate. This patch just makes it check the
truthiness immediately instead of waiting until after terminate is
called.

Change-Id: I41f93ca15a52dd45fc304dfd7d4c6d954ca26e42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208225
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-07-18 12:14:32 +02:00
..
…
…
…
…

Python UNO Bindings

UNO bindings for the Python programming language.

To have much joy debugging Python extensions you need to:

  • a) edit pythonloader.py in your install setting DEBUG=1 at the top
  • b) touch pyuno/source/module/pyuno_runtime.cxx and make debug=true in pyuno

Then you'll start to see your exceptions on the console instead of them getting lost at the UNO interface.

Python also comes with a gdb script libpython$(PYTHON_VERSION_MAJOR).$(PYTHON_VERSION_MINOR)m.so.1.0-gdb.py that is copied to instdir and will be auto-loaded by gdb; it provides commands like py-bt to get a Python-level backtrace, and py-print to print Python variables.

Another way to debug Python code is to use pdb: edit some initialization function to insert import pdb; pdb.set_trace() (somewhere so that it is executed early), then run soffice from a terminal and a command-line Python debugger will appear where you can set Python-level breakpoints.