Ask Your Question

Macro selector failing to find python macros

asked 2015-06-08 21:30:18 +0200

KeithSand gravatar image

updated 2015-06-11 01:27:41 +0200

The macro selector dialog in the tools menu is failing to spot macros in python code when there is a global tuple assignment (A, B = 1, 2 for example). The macros will run (via keyboard shortcut made before offending assignment put in module) so the script provider find the macros, and converting the tuple assignment to two normal assignments unblinds the macro selector dialog. Anyone else come across this behaviour? (tested in Calc only)

The full code that causes problems is

A, B = 1, 2
def myFunc():
    c = 1
g_exportedScripts = myFunc,

Commenting out the tuple assignment makes the function visible. It is always callable.

edit retag flag offensive close merge delete


yes, I can reproduce the issue, actually I dont know why it doesnt work...

karolus gravatar imagekarolus ( 2015-06-11 09:17:20 +0200 )edit

I've submitted bug 92007 please confirm!

karolus gravatar imagekarolus ( 2015-06-11 12:45:57 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-06-08 23:26:49 +0200

karolus gravatar image

updated 2015-06-11 12:08:51 +0200

From my slightly long experience with python: The common Case for ǹot showing some modules Content are trivial Syntax-Errors like missing closing braces|brackets|curly_braces or a missing : at the end of class|def|if|while|try|... lines.

After reproducing the issue I did some debugging, here's the patch for:

--- /opt/libreoffice4.4/program/  #old
+++ /opt/libreoffice4.4/program/   #new
@@ -403,7 +403,12 @@
             elif isinstance(node, ast.Assign):
                 for target in node.targets:
-                    if == "g_exportedScripts":
+                    try:
+                        identifier =
+                    except AttributeError:
+                        identifier = ""
+                        pass
+                    if identifier == "g_exportedScripts":
                         for value in node.value.elts:
                         return g_exportedScripts
edit flag offensive delete link more


To be sure most of the time that is the case with me. But not this time as I get the behaviour where the only other content in the module is a function with the one line 'c=1'. The macro runs - used a three line 'hello world' function to be sure.

KeithSand gravatar imageKeithSand ( 2015-06-09 16:03:23 +0200 )edit

so - please post the whole content, to give others a chance to reproduce the issue.

karolus gravatar imagekarolus ( 2015-06-09 16:54:47 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-06-08 21:30:18 +0200

Seen: 354 times

Last updated: Jun 11 '15