Bug 92007 - python scripts with tuple-assignments fails on access from GUI
Summary: python scripts with tuple-assignments fails on access from GUI
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
4.0 all versions
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.4.0 target:5.3.3
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-11 10:36 UTC by karolus
Modified: 2017-04-12 16:35 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
patch for $program/pythonscript.py (741 bytes, patch)
2015-06-11 10:59 UTC, karolus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description karolus 2015-06-11 10:36:41 UTC
In python its valid syntax making `tuple assignments` like:

x, y, z = 42, math.pi, 99

or PY3 also:

x, y , *all_the_rest = some_list_with_undefined_length

unfortunatly the functions in Scripts with those assignments, becomes no visible in the GUI.

here's the patch to fix this issue:

    --- /opt/libreoffice4.4/program/pythonscript.py	 #old
    +++ /opt/libreoffice4.4/program/pythonscript.py	 #new
    @@ -403,7 +403,12 @@
                     allFuncs.append(node.name)
                 elif isinstance(node, ast.Assign):
                     for target in node.targets:
    -                    if target.id == "g_exportedScripts":
    +                    try:
    +                        identifier = target.id
    +                    except AttributeError:
    +                        identifier = ""
    +                        pass
    +                    if identifier == "g_exportedScripts":
                             for value in node.value.elts:
                                 g_exportedScripts.append(value.id)
                             return g_exportedScripts
Comment 1 karolus 2015-06-11 10:59:16 UTC
Created attachment 116467 [details]
patch for $program/pythonscript.py
Comment 3 oz_dkj 2015-06-22 11:01:03 UTC
I also have this or a very similar problem:
tuple assignments at the global scope result in the functions in that script to become not visible from the GUI.
Comment 4 QA Administrators 2016-09-20 10:10:12 UTC Comment hidden (obsolete)
Comment 5 oz_dkj 2016-10-20 13:40:17 UTC
Bug still present with same behaviour in
  LibreOffice 5.1.5.2 (x64)
  Windows 10.0.14393
Comment 6 karolus 2016-10-20 14:52:52 UTC
Hi

@oz_dkj@yahoo.co.uk

On filing the bug I has already posted the fix …

… tomorrow is Bug-hunting-session for 5.3 …

but nobody of the Devs since 1 1/2 year was able to copy&paste 6 lines of sourcecode

that should frustrate many "bughunters"
Comment 7 Michael Stahl (allotropia) 2017-04-12 15:33:55 UTC
i'm sorry that nobody looked at this patch here, but generally developers don't often have time to search bugzilla for things that don't look like serious bugs, so we recommend to send patches to our gerrit code review server.

https://wiki.documentfoundation.org/Development/gerrit
Comment 8 Commit Notification 2017-04-12 15:34:23 UTC
Werner Tietz committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7ef47336411389ac492729bef52fe62aebe90f5a

tdf#92007 python scripts with tuple-assignments fails on access from GUI

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2017-04-12 16:35:05 UTC
Werner Tietz committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9a6d78b722f3a49f71a680e49cf64e7cfb637c43&h=libreoffice-5-3

tdf#92007 python scripts with tuple-assignments fails on access from GUI

It will be available in 5.3.3.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.