Commit Graph
876 Commits
Author SHA1 Message Date
Andrea Gelmini 850aab7852 Fix typos in code and comments + some reformatting.
Change-Id: I5b6d62104e46c6eb5d142e7e11666806383eed09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210566
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2026-09-10 15:15:58 +02:00
Michael Weghorn 4a8d42fc6d pyuno: Include Python.h first to avoid _POSIX_C_SOURCE redefinitions
As

    commit a545badd65
    Author: Stephan Bergmann <sbergman@redhat.com>
    Date:   Thu Feb 16 18:15:04 2012 +0100

        Work around macro redefinition warning

already did for pyuno/source/module/pyuno_dlopenwrapper.c ,
also include the <Python.h> header first
in more pyuno source files.

Quoting from the Python/C API reference manual about include
files [1]:

> Note: Since Python may define some pre-processor definitions
> which affect the standard headers on some systems, you must
> include Python.h before any standard headers are included.

This avoids build errors like the following otherwise seen
on Debian testing after a glibc update from 2.42-17 to 2.43-3:

    In file included from /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_struct.cxx:28:
    In file included from /home/michi/development/git/libreoffice/pyuno/source/module/pyuno_impl.hxx:26:
    In file included from /home/michi/development/git/libreoffice/workdir/UnpackedTarball/python3/Include/Python.h:14:
    /home/michi/development/git/libreoffice/workdir/UnpackedTarball/python3/pyconfig.h:1985:9: error: '_POSIX_C_SOURCE' macro redefined [-Werror,-Wmacro-redefined]
     1985 | #define _POSIX_C_SOURCE 200809L
          |         ^
    /usr/include/features.h:319:10: note: previous definition is here
      319 | # define _POSIX_C_SOURCE        202405L
          |          ^

[1] https://docs.python.org/3/c-api/intro.html#include-files

Change-Id: I4ae90cfc9b92b559181d3884cdc8d51ee11f922d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209871
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2026-08-26 11:39:00 +02:00
Neil Roberts aed5ae5d21 tdf#173114 pyuno: Add unit test for objects with XInvocation
Adds a service to embindtest that implements XInvocation to handle all
possible method names and returns the name as a string. A Python unit
test then uses this. Without the fix pyuno would throw an exception when
it tries to use the XInvocation object that doesn’t also implement
XInvocation2 and return a valid reference for getIntrospection.

Change-Id: Icb3359c788acd5eda37980252e5fc5c956b38100
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209087
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:43:09 +02:00
Neil Roberts 97302647ba tdf#173114 pyuno: Don’t require XInvocation2
If an object implements XInvocation then the Invocation service will
directly return the object instead of creating its own invocation
wrapper. In that case the object isn’t guaranteed to also implement
XInvocation2. Previously, this was making pyuno just throw an exception
whenever it encounters one of these objects.

The only case where XInvocation2 is actually used is the implementation
of the __dir__ method. I don’t think this method is used very often so
it’s probably OK to just make it return an empty list if XInvocation2
isn’t supported. That way we can just store a reference to XInvocation
instead of XInvocation2.

This change makes it possible to use objects that implement XInvocation
from Python, for example ooo.vba.excel.Application.

Change-Id: I822c4ffa760f52d6488b9c1009435d059fc19fdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209086
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:43:01 +02:00
Neil Roberts dcc46669fa tdf#173114 pyuno: Handle XInvocation::getIntrospection returning null
Many implementations of XInvocation for internal objects return null for
the getIntrospection method. In pyuno this method is only used in one
place to try and catch the case where the wrapped object is already a
PyUNO adapter. Let’s check for null in that case and assume the object
isn’t an adapter so that it won’t crash when handling objects that
implement XInvocation.

Change-Id: I26576a1a9fec92c679373d9ab47824d992065041
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209085
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-08-13 12:42:53 +02:00
Neil Roberts 935803f2f1 pyuno: Combine two implementations of PyUNO_dir into one
PyUNOStruct_dir is an almost exact copy of PyUNO_dir. This deletes the
first one and makes the struct code instead directly use PyUNO_dir. The
object version has the small advantage that it pre-allocates the Python
list to the right size so the struct code can now take advantage of that
too.

This will make it easier to modify the dir implementation for both use
cases in a later patch.

Change-Id: I7ebe2e6d547fd27c228842effd534e8d71d634ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209084
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-08-13 12:42:45 +02:00
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
Christopher Sherlock 3f65cecc11 pyuno: fix macOS test failures by routing officehelper to App Bundle
During local LODE builds on macOS, the test framework sets UNO_PATH
to `instdir/program`. While this works for Linux and Windows, macOS
builds generate a native application bundle, placing the executable
at `instdir/LibreOfficeDev.app/Contents/MacOS/soffice`.

This caused `subprocess.Popen` to throw a `FileNotFoundError` during
execution of targets like `PythonTest_pyuno_pytests_testofficehelper`.

This patch intercepts the macOS path in `bootstrap()` and dynamically
routes it to the correct LibreOfficeDev App Bundle location if the
default Linux-style path does not exist.

Additionally, this adds a standard Python 3 shebang to the file and
fixes a missing newline at EOF.

Change-Id: Ie92415941c24e0777087d51a999dcbeae6c06223
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208052
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
2026-07-15 20:59:17 +02:00
Neil Roberts d2429a3c46 pyuno: Reuse wrapped object when converting Python obj through UNO and back
When any2PyObject is given an interface which is actually an adapter for
a Python object, it now returns the original Python object instead of a
new wrapper for the object. This means that calling methods on the
returned object will be faster because they won’t involve UNO bridging.
It also means that Python implementations of UNO interfaces can detect
when they are given Python objects as a parameter and take advantage of
any internal private data attached to the object.

Change-Id: Ie13d0612f48e70973bd523e68710ec33a7875a16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207507
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-15 09:09:22 +02:00
David Hashe 83fcfc3ac4 pyuno: Set correct UNO_PATH on MacOS when running testofficehelper
MacOS uses a different soffice subdirectory than Windows and
Linux, so we need to use the appropriate macros.

Change-Id: I4b0fa077c330eaf0aac4f600fcfd83e4ebec7907
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207751
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-09 21:09:13 +02:00
Neil Roberts 715da59c42 testofficehelper: Retry connecting indefinitely
This test is sporadically failing on Jenkins. The test_default_config
test effectively only waits a total of 16 seconds for LibreOffice to
start up before giving up. The assumption is that this isn’t long enough
when the build bots are under heavy load from parallel testing.

This patch removes test_default_config and replaces the delays in the
other two tests with an infinite iterator so that it will keep trying to
connect every second forever. If there is a real problem launching
LibreOffice on Jenkins then eventually the kill-wrapper will kick in to
make the test fail.

Change-Id: I31c223892b7c5329c253c90703ec587874029d56
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207771
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-07-09 10:46:55 +02:00
Neil Roberts 5e3784870e pyuno/officehelper: Use f-strings instead of ''.join
This is probably slightly easier to understand.

Change-Id: If41ee1b3fd21d246447638056657d2ee56274ad8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206261
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-22 12:21:28 +02:00
Neil Roberts ef2cee37c5 pyuno: Set UNO_PATH when running testofficehelper
Otherwise the bootstrap function will just run whatever soffice
executable it finds in the PATH instead of the one built in the build
directory.

Change-Id: I122ca8efc80a7f134f7d06fb248ca1bc1108b0b3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206949
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-18 13:16:23 +02:00
Neil Roberts c1f4dc187b pyuno/officehelper: Let UNO_PATH work on macOS
On macOS a hard-coded path is used for the soffice binary. It probably
makes sense to avoid doing this if the UNO_PATH environment variable is
set.

Change-Id: I160bbec8a7ddffbb7032b55a61a3004e9d42bf18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206263
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-12 09:30:42 +02:00
Neil Roberts 40034e4b49 pyuno/officehelper: Simplify handling of UNO_PATH a little bit
Instead of calling os.path.join with an empty string when UNO_PATH is
not set, it is now only called when UNO_PATH is set.

Change-Id: I8ebf99d1849e62634860686c0bb4c9d0c2a9c0d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206262
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-12 09:30:16 +02:00
Neil Roberts b7224c8628 pyuno/officehelper: Let python quote process args instead of shell
subprocess.Popen can take an array argument with the arguments. If we do
this instead of trying to build up a single argument to pass to the
shell then we can let Python handle quoting the arguments on Windows.
This also means the executable path could contain spaces on platforms
other than Windows too.

Change-Id: I7779c5bab431b65cf4a602047c184fe78d802d77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206260
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-12 09:29:33 +02:00
Alain Romedenne e9723d4ebf tdf#163465 Add process cleanup in officehelper.py
officehelper processes remain active in memory unless scripters
intentionally stop them.
A new SessionMgr Python context manager is now taking care of
bootstraping a Libreoffice service as well as stopping it
automatically.

Change-Id: Icbc5886be371ad2aa8d8277e2476f5d89955d955
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206225
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
Tested-by: Jenkins
2026-06-12 09:28:05 +02:00
Neil Roberts 3223245186 pyuno: Don’t use PyObject_CallOneArg
That function was added in Python 3.9. Even though the LibreOffice
README says the baseline is 3.11, the configure script actually lets you
build with 3.3. I tested with Python 3.5 and it does work apart from
that function call and the fact that desktop-translate.py is using
f-strings. The call to PyObject_CallOneArg was added in the patch below
after the 26.2 branch point so it hasn’t been battle-tested in a release
version yet. Seeing as it’s easy to use an alternative let’s do that in
case someone is using a really old version of Python with pyuno for some
reason.

commit 45d2412c78
Author: Neil Roberts <bpeeluk@yahoo.co.uk>
Date:   Wed Feb 11 16:40:48 2026 +0100

    tdf#171122 pyuno: Add class getter methods for singletons

Change-Id: Ic6f7cf8d0005f59e8cbfd1f9703d393b7e30dabe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206333
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-11 08:23:25 +02:00
Neil Roberts 5e3838839d pyuno: Add testofficehelper to the pyuno module
Otherwise the tests aren’t actually run.

Change-Id: I781bcfe42726a7109e0494e02124690d34395232
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206259
Tested-by: Jenkins
Reviewed-by: Neil Roberts <nroberts@libreoffice.org>
2026-06-10 10:22:59 +02:00
AnamayNarkar cecee0d122 pyuno: fix const char* build error in dlopenwrapper.c
Building with clang 21.1.8 and --enable-werror fails because glibc 2.43
adopted the C23 behavior for strrchr(), where it now returns const char*
when its input is const char*. Assigning the result to a plain char*
discards the const qualifier, which clang rejects as an error since the flag is passed.

Change-Id: Ib8eecd603bedb4a69c8f7bd93e49f01e8eba28d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199863
Tested-by: Jenkins
Reviewed-by: Neil Roberts <bpeeluk@yahoo.co.uk>
2026-03-12 04:43:32 +01:00
Caolán McNamara 80d1e26362 cid#1684051 Overflowed integer argument
Change-Id: Ia2e3dc9b80f5bead409701a932b8e0c78baa1524
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201144
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2026-03-06 20:09:18 +01:00
Neil Roberts 8b022d0d0d pyuno: Add a unit test for singletons
As with the test for services, this uses the embindtest framework to
hide it behind --enable-embindtest-uno.

Change-Id: Ie64848926d21ca5c3edd449de85f4fed16b3b2aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199220
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-03-04 13:53:40 +01:00
Neil Roberts 45d2412c78 tdf#171122 pyuno: Add class getter methods for singletons
Makes it possible to import the name of a singleton into a Python script
as a class and then retrieve it with a getter method. Eg, instead of:

desktop = ctx.getValueByName(
    "/singletons/com.sun.star.frame.theDesktop")

you can now do:

from com.sun.star.frame import theDesktop
desktop = theDesktop.get(ctx)

Change-Id: I009bd2e890cde52aa6273e462621157fc1f63661
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199219
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-03-04 13:53:28 +01:00
Neil Roberts 2cd17a1148 Add a PythonTest for service constructors in pyuno
This leverages the existing framework for embindtest to add interfaces
and services to test with. Hopefully that means the tests will run on
the CI without ending up in the final release builds because they are
only enabled with --enable-embindtest-uno.

Change-Id: Idd394e616ad14943cecd60bf3a3e228d93166e34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199105
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-03-04 13:53:05 +01:00
Neil Roberts 346e0f8891 tdf#171122 pyuno: Handle service constructors
This makes it so that services can be imported in Python with code like
this:

from com.sun.star.resource import StringResourceWithLocation

And then an instance of the service can be constructed using any of its
constructors as a class method like this:

res = StringResourceWithLocation.create(ctx, root_url, True, locale,
                                        dlg, '', None)

This has the advantage that the number of arguments can be checked
properly and a more useful error message can be reported if they are not
correct. Because pyuno knows what types the arguments are supposed to
be, it can also do a better job of coercing them to the right ones. For
example in the example above it is possible to pass None for an
interface argument even though that normally represents the void type.

This idea evolved out of the discussion for tdf#169229.

Change-Id: I9b542178f1c101d58dcbbd241d4ecbc9fe38bc2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199104
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2026-03-04 13:52:55 +01:00
Stephan Bergmann cf49d618f4 Use direct PyUNO calls in PythonTest_pyuno_pytests_embindtest
...after 507b6c2b90 "tdf#169229: pyuno: Allow Any
when calling a method"

Change-Id: Ie91781abce253aece201605d0930344ddf8d1256
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195842
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-18 15:45:25 +01:00
Neil Roberts 68f8ddc153 Replace calls to uno.invoke with direct method call when just for Any
Now that the restriction on passing on Any as an argument to a method
has been lifted we can simplify some of the PythonTests that were
calling uno.invoke in order to pass an Any and just call the method
directly.

Change-Id: I14af4e3f50236e46f6108f8fea0284f696b59e44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195464
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-18 10:05:47 +01:00
Neil Roberts 507b6c2b90 tdf#169229: pyuno: Allow Any when calling a method
Previously when creating a callable object for an attribute on an
object (ie, a method), it would mark it with a special mode to disallow
passing a pyuno.Any as an argument. There doesn’t seem to be a good
reason to do this and it makes it difficult to use an explicit type when
calling a method that can take an Any. This patch instead just removes
the mode parameter from pyobject2Any entirely.

The example in the bug report is trying to call
createInstanceWithArgumentsAndContext which takes a Sequence of Anys as
an argument. Without this patch it is difficult to pass a null interface
as one of the arguments.

Change-Id: I8756bdc2821ebf247ff67a66f071263ac00e3890
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195452
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-18 10:05:39 +01:00
Stephan Bergmann 82413eb1f9 Improve PyUNO_cmp
...for cases where one operand is a PyUNO Adapter of the other (i.e., one
operand is a Python object that got passed out and back in again, and the other
operand is that same Python object).  This fixes the second "TODO" from
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest".

Change-Id: I0fc938db5c464ed56adee3b428537925fff0fc81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195392
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-11 21:24:20 +01:00
Stephan Bergmann f53a339292 More exhaustive testing of PyUNO type mapping based on embindtest
...by implementing all the getSequence... variants that were left out of
3320b5fe2e "Add exhaustive testing of PyUNO type
mapping based on embindtest".

Change-Id: Ia0dde7362484f83923999db68d80f57c7baa914c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195426
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-11 16:24:41 +01:00
Stephan Bergmann 6057f92cb4 Only use uno.Any when Runtime::pyObject2Any would produce the wrong result
Change-Id: I339f2c80383e59505cb68e3712e39b25df2636e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195355
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-10 21:28:19 +01:00
Stephan Bergmann 7bdd020783 Fix any2PyObject mapping of UNO exceptions
That

>             // the exception base functions want to have an "args" tuple,
>             // which contains the message

code is there ever since e80bdbafeb "initial
checkin for the pyuno-0.9.2 release" for reasons that are not clear to me, but
at least in the "TODO" scenarios from 3320b5fe2e
"Add exhaustive testing of PyUNO type mapping based on embindtest" and
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest" (which are hereby fixed), that
PyObject_SetAttrString would cause a Python exception, cf.

> info:pyuno.runtime:1489432:1489432:pyuno/source/module/pyuno_runtime.cxx:533: setting exception args raised Python exception <class 'AttributeError'>: AttributeError('args')

so at least catch that.  (And maybe that code is obsolete anyway it would make
even more sense to drop it altogether.)

Change-Id: Ic651d106f34e0b316cba59ae66d2402b8f86b0f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195340
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-10 07:58:18 +01:00
Stephan Bergmann d89051d184 Don't use OUStringBuffer::apendAscii with UTF-8
(Stumbled over this when while preparing
1e2e9a20a4 "More exhaustive testing of PyUNO type
mapping based on embindtest" I accidentally forgot the

> from org.libreoffice.embindtest import Exception

in pyuno/qa/pytests/embindtest.py and thus PythonTest_pyuno_pytests_embindtest
would SIGABRT with

> sal/rtl/strtmpl.hxx:122: auto rtl::str::Copy(sal_Unicode *, const char *, sal_Int32)::(anonymous class)::operator()(char) const: Assertion `rtl::isAscii(static_cast<unsigned char>(c))' failed.

from pyuno::lcl_ExceptionMessage (with reprString being "('error', None,
-123456, 100.5, 'hä')") while trying to report

> uno.com.sun.star.uno.RuntimeException: Couldn't convert ('error', None, -123456, 100.5, 'hä') to a UNO type; caught exception: <class 'AttributeError'>: 'Exception' object has no attribute 'getTypes', traceback follows

.)

Change-Id: I4581061dbfa190266fef98dc670a058d6c98eaaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195304
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2025-12-09 23:56:38 +01:00
Stephan Bergmann 1e2e9a20a4 More exhaustive testing of PyUNO type mapping based on embindtest
...by implementing all the getAny... variants that were left out of
5f05929fd1498e418618d7570192877055de2c80 "Add exhaustive testing of PyUNO type
mapping based on embindtest".

Which revealed that the code in Adapter::invoke (in
pyuno/source/module/pyuno_adapter.cxx) was apparently broken, and would cause
the C++ call in doExecuteTest (in unotest/source/embindtest/embindtest.cxx) of
the Python

>     def getAnyByte(self):
>         return uno.Any('byte', -12)

(in pyuno/qa/pytests/embindtest.py) to fail with a nonsensical

> uno.com.sun.star.uno.RuntimeException: uno.Any instance not accepted during method call, use uno.invoke instead at pyuno/source/module/pyuno_runtime.cxx:785 at stoc/source/invocation_adapterfactory/iafactory.cxx:203

In addition, there's two new places marked with TODO comments:

For one, executing C++

>         bool const ok = test->isAnyException(val);

would cause an odd

> python.bin: Objects/typeobject.c:4745: PyObject *_PyType_Lookup(PyTypeObject *, PyObject *): Assertion `!PyErr_Occurred()' failed.

failure that needs further investigation.

And for another, executing Python

>         return value == self

would always return false.  It appears that PyUNO_cmp (in
pyuno/source/module/pyuno.cxx isn't yet prepared to be called with `that` being
a native Python UNO-implemenation object (`class Test(unohelper.Base, XTest)`)
instead of a proxy for a binary/C++ UNO object.

Change-Id: I0289e1f5ee6dab53b589af783c0c53302989394c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195287
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
2025-12-09 14:00:54 +01:00
Stephan Bergmann 3320b5fe2e Add exhaustive testing of PyUNO type mapping based on embindtest
...in preparation for doing fixes for tdf#169229 "PyUNO: Hard to create null UNO
interface references, to use in a method invocation" etc.  (Basing it on
embindtest means it requires --enable-embindtest-uno, at least for now.)

Various places in pyuno/qa/pytests/embindtest.py are marked with TODO comments.
(Executing

>         v = test.getAnyException()

would cause an odd

> Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set

failure that needs further investigation.)

To not only test calls from PyUNO to binary (C++) UNO, but also from binary
(C++) UNO to PyUNO, add an executeTest method to the
org.libreoffice.embindtest.XTest interface.  For now, it only does those tests
that were already done by the org.libreoffice.embindtest.BridgeTest service
implementation, but the plan is to extend those (e.g., don't just only test
getAnyVoid, but all the getAny... variants).  And the corresponding Test class
implementation in pyuno/qa/pytests/embindtest.py for now only defines those
methods that are actually called, and will need to be extended as well.

Change-Id: I0dd66b9aed14cc7e679da78b86d0dc657625fe94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195238
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Tested-by: Jenkins
2025-12-08 21:28:43 +01:00
Mike Kaganski b0390a4d1b Drop unohelper.absolutize, and use uno.absolutize to avoid duplication
Change-Id: I9e3b10c5c9b0a0ef1af66c99732bb217d37c3851
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194073
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-11-16 19:10:57 +01:00
Mike Kaganski efd69fbd84 Use XVndSunStarExpandUrl::expand directly, instead of re-implementing it
Make it similar to comphelper::getExpandedUri.

Change-Id: I8674a3ad86b94dc76dbce81b043fa4b70543fbb6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194069
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
2025-11-16 15:47:39 +01:00
Xisco Fauli 6408a49ac5 tdf#168513: python3: bundle lzma
Change-Id: I7b9729cd293aea781b204888236c3aa5aa858eaa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193739
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2025-11-11 21:40:00 +01:00
Xisco Fauli 4bf59e9258 python3: bundle _hashlib on Windows too
as Linux and MacOS already do

Change-Id: I42aae48a35e72b540a7fda51bb5907de2de64aab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193288
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2025-11-03 15:27:55 +01:00
Xisco Fauli 3d57e6a9b5 tdf#132074: python3: bundle dbm
Change-Id: I1ed3c6e834f486cc8753513dfb03a2a0d4a8cfd4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193155
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Tested-by: Jenkins
2025-10-29 18:58:53 +01:00
Xisco Fauli 89e04610de pyuno: Combine all import tests into one file
It makes it easier to add new ones

Change-Id: Icfea450bf4e6b6efb4d4a9644706303b2e8059a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193154
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-10-29 17:17:41 +01:00
Xisco Fauli 1dfb0c9936 tdf#168512: python3: bundle sqlite3
Add sqlite3.patch.1 since sqlite3.vcxproj expects the
sqlite version in the path

Change-Id: Ieb262b5401447cc9cc8c8d68197b3ec492c6ed94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191394
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-10-29 14:21:29 +01:00
Mike Kaganski 641e8b1875 Drop loplugin:stringadd exclusion for pyuno_runtime.cxx
Change-Id: I362f4322fd0948b83272234e4fe52a957aea5f9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191578
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-09-28 19:03:11 +02:00
Gabor Kelemen 99324a10c8 bin/find-unneeded-includes: add exception for URE header
osl/file.hxx, so that these can be removed from per-module yaml files

Change-Id: Iad0a6ab19ea34701e06ce356eaab4139205c8ad3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191341
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2025-09-26 17:53:37 +02:00
Gabor Kelemen 93d74ca574 bin/find-unneeded-includes: add exception for URE header
rtl/bootstrap.hxx, so that these can be removed from per-module yaml files

Change-Id: I785e9656b76efe5c2b663983637a08b3d7cf2aee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191338
Tested-by: Jenkins
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
2025-09-25 09:38:45 +02:00
Xisco Fauli dcd517331c related tdf#168511: bundle venv on mac too + Add test
I missed it in
commit dd8c42bf4b
Author: Xisco Fauli <xiscofauli@libreoffice.org>
Date:   Tue Sep 23 10:07:26 2025 +0200

    tdf#168511: python3: bundle venv

Change-Id: I180df8df27ece92aaa1feca379d280ff3f1ba2de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191392
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-09-23 14:18:34 +02:00
Mike Kaganski 3a4961af43 Use o3tl::{get,set}Environment instead of resp. osl_* functions
Simplifies the code, and avoids OUString internals access.
Also replace some getenv calls.

Change-Id: I5f7dc492fe87ea1fbaad6a61bc54e21f0f0c5aef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187974
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2025-07-17 07:03:19 +02:00
Caolán McNamara b80cd12449 const up some more pieces
Change-Id: Ib85b8b4b3a2d00e7ef0ecb354fba0b862d60abdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187749
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
2025-07-12 01:16:21 +02:00
Xisco Fauli 528cdd6573 python3: upgrade to 3.12.11 (master only)
* Py_DontWriteBytecodeFlag is deprecated now, replace it with
PyConfig.write_bytecode

* setuptools and pip are no longer available by default on mac.
Get them from the wheel files the same way linux and windows do

Downloaded from https://www.python.org/ftp/python/3.12.11/Python-3.12.11.tar.xz

Change-Id: Id1043671d8fbb6b3bfa39afbf6aedd634c92c5f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181785
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-06-17 20:39:18 +02:00
Xisco Fauli f775f6766a pyuno: no need to add lib-tk to path
Change-Id: Ie86ba52ab2e8df66cabe75acaf440b2ca076f4c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186580
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2025-06-16 21:19:55 +02:00