This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch AOO50X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit de9f4dfb314cd37b92c7b2a2537a76fbeb1dc061
Author: Jim Jagielski <[email protected]>
AuthorDate: Tue Nov 10 06:10:44 2026 -0500

    pyuno: don't let dir() throw a UNO exception into the interpreter
    
    An exception from getMemberNames() escaped PyUNO_dir and ended in
    std::terminate; it now reaches Python as an exception, as it should.
    
    (cherry picked from commit 5aeeddd15cbaf924549e530f93103b21a7e9e016)
---
 main/pyuno/source/module/pyuno.cxx | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/main/pyuno/source/module/pyuno.cxx 
b/main/pyuno/source/module/pyuno.cxx
index 18ab58621d..fb6ff2bd63 100644
--- a/main/pyuno/source/module/pyuno.cxx
+++ b/main/pyuno/source/module/pyuno.cxx
@@ -652,12 +652,12 @@ static PyObject *PyUNO_dir( PyObject *self, PyObject 
*that )
     Sequence<OUString> oo_member_list;
 
     me = (PyUNO*) self;
-    Reference< XInvocation2 > inv2( me->members->xInvocation, UNO_QUERY );
-    if( inv2.is() )
-        oo_member_list = inv2->getMemberNames ();
-    else
+    try
     {
-        try
+        Reference< XInvocation2 > inv2( me->members->xInvocation, UNO_QUERY );
+        if( inv2.is() )
+            oo_member_list = inv2->getMemberNames ();
+        else
         {
             Runtime runtime;
             std::vector< OUString > names;
@@ -677,16 +677,16 @@ static PyObject *PyUNO_dir( PyObject *self, PyObject 
*that )
             for( size_t k = 0 ; k < names.size() ; k ++ )
                 oo_member_list[k] = names[k];
         }
-        catch( com::sun::star::uno::RuntimeException &e )
-        {
-            raisePyExceptionWithAny( makeAny( e ) );
-            return NULL;
-        }
-        catch( com::sun::star::uno::Exception &e )
-        {
-            raisePyExceptionWithAny( makeAny( e ) );
-            return NULL;
-        }
+    }
+    catch( com::sun::star::uno::RuntimeException &e )
+    {
+        raisePyExceptionWithAny( makeAny( e ) );
+        return NULL;
+    }
+    catch( com::sun::star::uno::Exception &e )
+    {
+        raisePyExceptionWithAny( makeAny( e ) );
+        return NULL;
     }
     member_list = PyList_New (oo_member_list.getLength ());
     for (int i = 0; i < oo_member_list.getLength (); i++)

Reply via email to