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


I ran into a behavioral change with LibreOffice 3.5 and comparing uno
objects in Python, and was wondering if anyone else have run into
this.  It seems to be a bug to me, but perhaps what I'm doing is no
longer valid (or perhaps was never guaranteed behavior)?

Specifically, up through LibreOffice 3.4.5, I was able to directly
compare two uno objects in Python, and the comparison result was true
if the individual fields matched (specifically the "value" contents in
the wrapped object were equal).  However, with 3.5, that is no longer
true, even though individually comparing the fields shows they are
equal.

The wrapper code in uno.py (_uno_struct__eq__, which compares the
"value" contents) still seems to be in place (and being called), so
the issue appears to be that the comparing value attributes has changed
behavior in 3.5.

I'm seeing the problem with 3.5.1RC1, but I couldn't test with 3.5.0
due to the Python uno wrapper loading bug.

I ran into the problem in a much larger script I've used for a few years
(starting back with OpenOffice), but as a minimal example:

    # unocmp.py

    import uno
    from com.sun.star.style import TabStop

    LEFT = uno.Enum("com.sun.star.style.TabAlign", "LEFT")

    if __name__ == "__main__":
        a = TabStop()
        a.Position = 1000
        a.Alignment = TABALIGN_LEFT
        a.DecimalChar = '.'
        a.FillChar = ' '

        b = TabStop()
        b.Position = 1000
        b.Alignment = TABALIGN_LEFT
        b.DecimalChar = '.'
        b.FillChar = ' '

        print 'A:', type(a), a.__class__
        print 'A:', a
        print 'B:', type(b), b.__class__
        print 'B:', b
        print 'A==B:', a == b, a.value == b.value
        print 'FIELDS:'
        for field in ('Position', 'Alignment', 'DecimalChar', 'FillChar'):
            print '  ', field, getattr(a,field) == getattr(b,field)

What has been true up to this point is the objects a and b compare equal.
But here's the 3.4.5 and 3.5.1RC1 output:

/opt/libreoffice3.4/program/python unocmp.py

A: <type 'instance'> uno.com.sun.star.style.TabStop
A: (com.sun.star.style.TabStop){ Position = (long)0x3e8, Alignment = 
(com.sun.star.style.TabAlign)LEFT, DecimalChar = (char)'.', FillChar = (char)' ' }
B: <type 'instance'> uno.com.sun.star.style.TabStop
B: (com.sun.star.style.TabStop){ Position = (long)0x3e8, Alignment = 
(com.sun.star.style.TabAlign)LEFT, DecimalChar = (char)'.', FillChar = (char)' ' }
A==B: True True
FIELDS:
   Position True
   Alignment True
   DecimalChar True
   FillChar True

/opt/libreoffice3.5/program/python unocmp.py

A: <class 'uno.com.sun.star.style.TabStop'> <class 'uno.com.sun.star.style.TabStop'>
A: (com.sun.star.style.TabStop){ Position = (long)0x3e8, Alignment = 
(com.sun.star.style.TabAlign)LEFT, DecimalChar = (char)'.', FillChar = (char)' ' }
B: <class 'uno.com.sun.star.style.TabStop'> <class 'uno.com.sun.star.style.TabStop'>
B: (com.sun.star.style.TabStop){ Position = (long)0x3e8, Alignment = 
(com.sun.star.style.TabAlign)LEFT, DecimalChar = (char)'.', FillChar = (char)' ' }
A==B: False False
FIELDS:
   Position True
   Alignment True
   DecimalChar True
   FillChar True

So 3.4.5 passes the comparison (the A==B) line while 3.5.1RC1 does
not.  However, you can see the object representations (and individual
field comparisons) remain true in 3.5.1RC1.

There is a clear difference in the wrapper (the types versus instances) so
I'm thinking something might have been missed in that change, though I'm not quite sure where to 
start looking.

Any thoughts would be appreciated.

-- David


-- 
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

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.