Bug 125307 - PyUno wrongly converts Tuples of Strings
Summary: PyUno wrongly converts Tuples of Strings
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
(earliest affected)
5.2 all versions
Hardware: All All
: medium normal
Assignee: Not Assigned
Whiteboard: target:6.4.0
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
Reported: 2019-05-15 12:44 UTC by Thomas Viehmann
Modified: 2020-11-24 15:04 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Viehmann 2019-05-15 12:44:03 UTC
Some uno functions, e.g. XPropertySet.setPropertyValue, accept arguments that can be of type Any("[]String").

Calling such a method with a tuple of strings (which would correspond to what's returned by getProperty) gives "inappropriate property value".

What appears to happen (from debugging with  PYSCRIPT_LOG_LEVEL=DEBUG PYUNO_LOGLEVEL=ARGS ) is that the tuple of strings get's converted into a Any of type []Any with each element of the list being an Any of type String.

Manually calling with

uno.invoke(..., "setPropertyValue", ("myprop", uno.Any("[]String", mytupleofstr)))

works, as described in


Steps to Reproduce:
Create a property of type []String in a python extension.
Try to read -> works, gives tuple of Strings.
Try to write -> doesn't work, uno.invoke works.

Actual Results:
try     py->uno[0x561181e85c80].setPropertyValue((string)"lstFoo", ([]any){ (any){ (string)"Apples" }, (any){ (string)"Bananas" }, (any){ (string)"Oranges" }, (any){ (string)"Grapes" } })
except  py->uno[0x561181e85c80].setPropertyValue = (com.sun.star.lang.IllegalArgumentException){ (com.sun.star.uno.RuntimeException){ (com.sun.star.uno.Exception){ Message = (string)"configmgr inappropriate property value", Context = (com.sun.star.uno.XInterface)0x56117709f6e0 } }, ArgumentPosition = (short)0x-1 }

Expected Results:
Conversion being to Any("[]String", ...).

Reproducible: Always

User Profile Reset: No

Additional Info:
Comment 1 Stephan Bergmann 2019-05-16 07:53:24 UTC
see the mailing list thread starting at <https://lists.freedesktop.org/archives/libreoffice/2019-May/082763.html> "Converting Python Tuples / Lists into Any in PyUNO"
Comment 3 Thomas Viehmann 2019-05-18 05:58:44 UTC
Thanks Oliver! Those are great resources! (And I do sometimes look at the grammalecte plugin for inspiration of how PyUNO works, too)

So slide 18 (Elimination of explicit Any) is very close to my case. The implicit conversion to any here would be not to "string[]" as I would expect from the example, but to any[].

Maybe you or Matthew have an opinion on whether that's intentional or maybe less so?
Comment 4 Olivier R. 2019-05-26 06:37:15 UTC
Actually, I haven’t tried these new syntaxes for compatibility issues with older versions of LibreOffice. But as I dropped support for LOs < 5.3 recently, I will try that when I have the courage to dig in my code.

But I’m not familiar at all with LibreOffice internals, I have no opinion on your issue. I’m even surprised that my plugin could be inspirative, as I often feel more like I’m struggling with the LO API than really using it.
Comment 5 Thomas Viehmann 2019-09-19 12:18:18 UTC
So there is a brief discussion here:
(I didn't do the research mentioned there, though)

When we shy away from changing the auto-conversion, a partial mitigation might be to allow Any arguments to be passed to methods.
This would still have us doing the Any conversion explicitly, but we would not have to resort to uno.invoke, giving a 50% more pythonic feel to it.
Comment 6 Commit Notification 2019-09-19 18:00:44 UTC
Bjoern Michaelsen committed a patch related to this issue.
It has been pushed to "master":


tdf#125307: move range properties check to own test

It will be available in 6.4.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:

Affected users are encouraged to test the fix and report feedback.
Comment 7 Xisco Faulí 2019-12-03 10:56:45 UTC
A polite ping to Thomas Viehmann:
Is this bug fixed? if so, could you please close it as RESOLVED FIXED ?
Otherwise, Could you please explain what's missing?
Comment 8 Thomas Viehmann 2019-12-03 11:27:17 UTC
This issue continues to exist. The problem is that it is potentially backwards compatibility-breaking to fix it (see the mailing list discussion).
Comment 9 Thomas Viehmann 2020-11-24 15:04:24 UTC
This is another instance: