Bug 150926 - An identity function implemented in Python does not evaluate equal to itself
Summary: An identity function implemented in Python does not evaluate equal to itself
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.4.0.3 release
Hardware: All All
: medium normal
Assignee: Eike Rathke
URL:
Whiteboard: target:7.5.0 target:7.3.7 target:7.4.2
Keywords: bibisectNotNeeded, regression
Depends on:
Blocks:
 
Reported: 2022-09-13 09:59 UTC by Mike Kaganski
Modified: 2022-09-15 05:05 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
The testing extension used in the forum.openoffice.org topic (3.29 KB, application/vnd.openofficeorg.extension)
2022-09-13 09:59 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Kaganski 2022-09-13 09:59:19 UTC
Created attachment 182402 [details]
The testing extension used in the forum.openoffice.org topic

As discussed in https://forum.openoffice.org/en/forum/viewtopic.php?p=389232:

Installing this extension, and using the simple spreadsheet function that it introduced, gives this unexpected result since v.5.4:

=PYSTRINGTEST("abc")=PYSTRINGTEST("abc")

gives FALSE. In previous versions, and in other OOo derivatives, it produces expected TRUE.

The function is implemented to simply return its argument (see the linked forum thread).
Comment 1 Werner Tietz 2022-09-13 12:07:04 UTC
The IDL-definition used in the extension looks wrong, IHMO it should be:

```
#include <com/sun/star/uno/XInterface.idl>
 
module org { module pystrings { module pystringtest {
 
    interface XPyStringTest
    {
        string pystringtest( [in] string teststring);
    };
 
}; }; };

```
Comment 2 Mike Kaganski 2022-09-13 12:46:45 UTC
(In reply to Werner Tietz from comment #1)

IIUC, the function takes a 2D array, which is how ranges are passed to functions; so the function takes (and returns) a range (of strings).

Having in A1:B3:

a d
b e
c f

putting in C1:

=PYSTRINGTEST(A1:B3)

(not as array formula) gives "a" in C1 (by intersection); if C1 contains

=CONCAT(PYSTRINGTEST(A1:B3))

then C1 has "adbecf", because CONCAT takes the whole returned array.

But in this case, putting this to C1:

=PYSTRINGTEST(A1:B3)=PYSTRINGTEST(A1:B3)

also returns the unexpected FALSE.

So regardless of the intention (and correctness for author's purpose), the IDL seems OK-ish, and seems that it *should* work, with comparison of the array to the same-dimension same-content array looking also well-defined.
Comment 3 Werner Tietz 2022-09-13 14:48:17 UTC
IHMO regardless of the intention, the function should work like any other formula taking a single argument by DEFAULT and evaluates also 2-dim-arrays OPTIONAL, that exactly works with the suggested change
Comment 4 Mike Kaganski 2022-09-13 15:51:35 UTC
(In reply to Werner Tietz from comment #3)

Your suggested change does *not* "evaluate also 2-dim-arrays OPTIONAL", it only allows taking a scalar value (string) inside the function. If you imply that the function could be used inside an array formula, you declare that no add-in function may ever take arrays (and make that the API contract).
Comment 5 Eike Rathke 2022-09-13 21:40:06 UTC
A short debugging revealed that the cause is the matrix/array elements' strings are svl::SharedString but apparently not interned, thus comparing the pointers of different instances yields false.
Comment 6 Commit Notification 2022-09-14 07:02:32 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a56e5434a4ed453b55b8f060ed18404d77a9fb10

Resolves: tdf#150926 Add-In result svl::SharedString needs to be interned

It will be available in 7.5.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.
Comment 7 Eike Rathke 2022-09-14 07:18:04 UTC
Pending review
https://gerrit.libreoffice.org/c/core/+/139841 for 7-4
https://gerrit.libreoffice.org/c/core/+/139842 for 7-3
Comment 8 Commit Notification 2022-09-15 05:05:42 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/32da7faefc6568bf07f27eedaae5488fdf68cb65

Resolves: tdf#150926 Add-In result svl::SharedString needs to be interned

It will be available in 7.3.7.

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.
Comment 9 Commit Notification 2022-09-15 05:05:53 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

https://git.libreoffice.org/core/commit/2919441c102122455b7b9967885a0a8a342eff56

Resolves: tdf#150926 Add-In result svl::SharedString needs to be interned

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