Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi Alexander, *,

On Mon, Jun 27, 2011 at 5:14 PM, Alexander Thurgood
<alex.thurgood@gmail.com> wrote:

MacOSX_10.6.7_Intel_no-moz/master/2011-06-27_08.26.21

There is no Python script menu entry in the Tools > Macros > Organise UI
menu, only Basic, Javascript and Beanshell.

This is caused by

commit 5f1a059d37501f2b26cd387e2b1f096f6272c004
Author: Andreas Becker <atayoohoo@googlemail.com>
Date:   Sat May 7 20:35:03 2011 +0100

    Port PyUno to support Python 3

to the URE module.
This patch is bad in a sense as it mixes whitespace changes with
functional changes and introduces bugs at the same time :-(

From git log -p -b (i.e. ignore whitespace only changes:
--- a/pyuno/source/loader/pythonloader.py
+++ b/pyuno/source/loader/pythonloader.py
@@ -49,16 +49,16 @@ g_loadedComponents = {}
 def checkForPythonPathBesideComponent( url ):
       path = unohelper.fileUrlToSystemPath( url+"/pythonpath.zip" );
       if DEBUG == 1:
-            print "checking for existence of " + encfile( path )
+        print("checking for existence of " + encfile( path ))
       if 1 == os.access( encfile( path ), os.F_OK) and not path in sys.path:
             if DEBUG == 1:
-                  print "adding " + encfile( path ) + " to sys.path"
+            print("adding " + encfile( path ) + " to sys.path")
             sys.path.append( path )

       path = unohelper.fileUrlToSystemPath( url+"/pythonpath" );
       if 1 == os.access( encfile( path ), os.F_OK) and not path in sys.path:
             if DEBUG == 1:
-                  print "adding " + encfile( path ) + " to sys.path"
+            print("adding " + encfile( path ) + " to sys.path")
             sys.path.append( path )

 def encfile(uni):
###########################

So already in the first hunk that is not whitespace-only, it changes
the alignment of the print statement from the last if-clause to the
wrong level.. This is noticable in various places.

But what makes it incompatible with Mac are those:

@@ -113,13 +113,13 @@ class Loader( XImplementationLoader,
XServiceInfo, unohelper.Base ):
                 else:
                       raise RuntimeException( "PythonLoader: Unknown
protocol " +
                                               protocol + " in url "
+url, self )
-          except ImportError, e:
-                raise RuntimeException( "Couldn't load "+url+ " for
reason "+str(e), None)
+        except ImportError as e:
+            raise RuntimeException( "Couldn't load " + url + " for
reason " + str(e), None )
           return None

       def activate( self, implementationName, dummy, locationUrl, regKey ):
          if DEBUG:
-            print "pythonloader.Loader.activate"
+            print("pythonloader.Loader.activate")

          mod = self.getModuleFromUrl( locationUrl )
           implHelper = mod.__dict__.get( "g_ImplementationHelper" , None )
###########################

I.e. "except ImportError as e" is a syntax error in python 2.3, you
need to keep it as "except ImportError, e" - same for various other
places.

So I ask Andreas Becker to either revert and apply a clean version of
the Python 3 relevant changes /only/ (i.e. without the whitespache
changes all over the place), or to go through the whole thing again
and make sure that the indendation still matches the original
versions.

AFAICT the only think that is python 3 relevant is to put the argument
to print in parentheses.

Especially this change:

@@ -104,7 +104,7 @@ class Loader( XImplementationLoader, XServiceInfo,
unohelper.Base ):

                             # compile and execute the module
                             codeobject = compile( src,
encfile(filename), "exec" )
-                            exec codeobject in mod.__dict__
+                    exec(codeobject, mod.__dict__)
                             mod.__file__ = encfile(filename)
                             g_loadedComponents[url] = mod
                       return mod
########
just is not right, is it?

ciao
Christian

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.