<div>Hello all,</div><div> </div><div>I rebuilt master with the latest changes made by Michael Stahl, Michael Meeks and Julien Nabet and desktop.addTerminateListener(TerminateListenerProcAdapter(test)) does not fail anymore. However, print(dir(desktop)) still yells the same problem.</div>
<div>Anyway, I could already launch fax wizard using python3.3 so this is a big step foward. Thank you to all of you guys.</div><div> </div><div>Regards,</div><div>Xisco Faulí<br></div><div class="gmail_quote">2012/11/22 Xisco Faulí <span dir="ltr"><<a href="mailto:anistenis@gmail.com" target="_blank">anistenis@gmail.com</a>></span><br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">Hello all,<div><br></div><div>I built libreoffice with python3.3 today in order to adapt python code to this version and I realized python3.3 has a different behaviour interacting with UNO components than python2.7 does. Just to check it I created a simple script:</div>

<div><br></div><div><div>import unohelper</div><div>    </div><div>def test():</div><div>    localContext = uno.getComponentContext()</div><div>    resolver = localContext.ServiceManager.createInstanceWithContext(</div><div>

                    "com.sun.star.bridge.UnoUrlResolver", localContext )</div><div>    ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )</div><div>    smgr = ctx.ServiceManager</div>

<div>    desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)</div><div>    print(dir(desktop))</div><div>    desktop.addTerminateListener(TerminateListenerProcAdapter(test))</div><div>    model = desktop.getCurrentComponent()</div>

<div>    text = model.Text</div><div>    cursor = text.createTextCursor()</div><div>    text.insertString( cursor, "Hello World", 0 )</div><div>    ctx.ServiceManager</div><div><br></div><div>from com.sun.star.frame import XTerminateListener</div>

<div>class TerminateListenerProcAdapter(unohelper.Base, XTerminateListener):</div><div>    def __init__( self, oProcToCall):</div><div>        self.oProcToCall = oProcToCall</div><div><br></div><div>if __name__ == "__main__":</div>

<div>    test()</div></div><div><br></div><div>in python2.7 it works perfecty but in python3.3 it throws 2 exceptions.</div><div><br></div><div>print(dir(desktop)):</div><div><br></div><div><div>Traceback (most recent call last):</div>

<div>  File "test.py", line 25, in <module></div><div>    test()</div><div>  File "test.py", line 11, in test</div><div>    print(dir(desktop))</div><div>TypeError: object does not provide __dir__</div>

<div>Error in sys.excepthook:</div><div>Traceback (most recent call last):</div><div>  File "/home/xisco/libo/install/program/uno.py", line 286, in _uno_import</div><div>    d[x] = pyuno.getClass( name + "." + x )</div>

<div>uno.RuntimeException: pyuno.getClass: uno exception apport.fileutils.likely_packaged is unknown</div><div><br></div><div>During handling of the above exception, another exception occurred:</div><div><br></div><div>Traceback (most recent call last):</div>

<div>  File "/home/xisco/libo/install/program/uno.py", line 290, in _uno_import</div><div>    d[x] = Enum( name , x )</div><div>  File "/home/xisco/libo/install/program/uno.py", line 123, in __init__</div>

<div>    pyuno.checkEnum( self )</div><div>uno.RuntimeException: attributes typeName and/or value of uno.Enum are not strings</div><div><br></div><div>During handling of the above exception, another exception occurred:</div>

<div><br></div><div>Traceback (most recent call last):</div><div>  File "/home/xisco/libo/install/program/uno.py", line 294, in _uno_import</div><div>    d[x] = getConstantByName( name + "." + x )</div>

<div>  File "/home/xisco/libo/install/program/uno.py", line 48, in getConstantByName</div><div>    return pyuno.getConstantByName( constant )</div><div>uno.RuntimeException: apport.fileutils.likely_packaged</div>

<div><br></div><div>During handling of the above exception, another exception occurred:</div><div><br></div><div>Traceback (most recent call last):</div><div>  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook</div>

<div>    from apport.fileutils import likely_packaged, get_recent_crashes</div><div>  File "/home/xisco/libo/install/program/uno.py", line 297, in _uno_import</div><div>    raise ImportError( "type "+ name + "." +x + " is unknown" )</div>

<div>ImportError: type apport.fileutils.likely_packaged is unknown</div><div><br></div><div>Original exception was:</div><div>Traceback (most recent call last):</div><div>  File "test.py", line 25, in <module></div>

<div>    test()</div><div>  File "test.py", line 11, in test</div><div>    print(dir(desktop))</div><div>TypeError: object does not provide __dir__</div></div><div><br></div><div>and desktop.addTerminateListener(TerminateListenerProcAdapter(test)) ( comenting previous line):</div>

<div><br></div><div><div>Traceback (most recent call last):</div><div>  File "test.py", line 25, in <module></div><div>    test()</div><div>  File "test.py", line 12, in test</div><div>    desktop.addTerminateListener(TerminateListenerProcAdapter(test))</div>

<div>uno.RuntimeException: Couldn't convert <__main__.TerminateListenerProcAdapter object at 0xb70cb9ec> to a UNO type; caught exception: attributes typeName and/or value of uno.Enum are not strings</div><div>Error in sys.excepthook:</div>

<div>Traceback (most recent call last):</div><div>  File "/home/xisco/libo/install/program/uno.py", line 286, in _uno_import</div><div>    d[x] = pyuno.getClass( name + "." + x )</div><div>uno.RuntimeException: pyuno.getClass: uno exception apport.fileutils.likely_packaged is unknown</div>

<div><br></div><div>During handling of the above exception, another exception occurred:</div><div><br></div><div>Traceback (most recent call last):</div><div>  File "/home/xisco/libo/install/program/uno.py", line 290, in _uno_import</div>

<div>    d[x] = Enum( name , x )</div><div>  File "/home/xisco/libo/install/program/uno.py", line 123, in __init__</div><div>    pyuno.checkEnum( self )</div><div>uno.RuntimeException: attributes typeName and/or value of uno.Enum are not strings</div>

<div><br></div><div>During handling of the above exception, another exception occurred:</div><div><br></div><div>Traceback (most recent call last):</div><div>  File "/home/xisco/libo/install/program/uno.py", line 294, in _uno_import</div>

<div>    d[x] = getConstantByName( name + "." + x )</div><div>  File "/home/xisco/libo/install/program/uno.py", line 48, in getConstantByName</div><div>    return pyuno.getConstantByName( constant )</div>

<div>uno.RuntimeException: apport.fileutils.likely_packaged</div><div><br></div><div>During handling of the above exception, another exception occurred:</div><div><br></div><div>Traceback (most recent call last):</div><div>

  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 64, in apport_excepthook</div><div>    from apport.fileutils import likely_packaged, get_recent_crashes</div><div>  File "/home/xisco/libo/install/program/uno.py", line 297, in _uno_import</div>

<div>    raise ImportError( "type "+ name + "." +x + " is unknown" )</div><div>ImportError: type apport.fileutils.likely_packaged is unknown</div><div><br></div><div>Original exception was:</div>

<div>Traceback (most recent call last):</div><div>  File "test.py", line 25, in <module></div><div>    test()</div><div>  File "test.py", line 12, in test</div><div>    desktop.addTerminateListener(TerminateListenerProcAdapter(test))</div>

<div>uno.RuntimeException: Couldn't convert <__main__.TerminateListenerProcAdapter object at 0xb70cb9ec> to a UNO type; caught exception: attributes typeName and/or value of uno.Enum are not strings</div></div>
<div>
<br></div><div><br></div><div>any idea ?</div><div><br></div><div>Regards,</div><div>Xisco Faulí</div><div><br></div>
</blockquote></div><br>