[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - pyuno/source

2012-03-12 Thread Caolán McNamara
 pyuno/source/module/pyuno.cxx |   13 ++---
 pyuno/source/module/uno.py|   14 ++
 2 files changed, 20 insertions(+), 7 deletions(-)

New commits:
commit 94541ebd9eb95a47f40bac95f5f6982a562e5a4d
Author: Michael Stahl mst...@redhat.com
Date:   Fri Mar 9 11:28:28 2012 +0100

fdo#46926: fix the fix for Python 3

Thanks to Maxime de Roucy for the hint that the cmpfunc type doesn't 
exist.
(cherry picked from commit 06484b6946ac6a974c24af6624fb75bbe298c1e8)

Signed-off-by: Caolán McNamara caol...@redhat.com

diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index 82e29ac..7f5f0b5 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -661,7 +661,7 @@ static PyTypeObject PyUNOType =
 (printfunc) 0,
 (getattrfunc) PyUNO_getattr,
 (setattrfunc) PyUNO_setattr,
-(cmpfunc) 0,
+/* this type does not exist in Python 3: (cmpfunc) */ 0,
 (reprfunc) PyUNO_repr,
 0,
 0,
commit fc290187f08981c734d1f2d3f6649c94e3ac6f99
Author: David Bolen db3l@gmail.com
Date:   Wed Mar 7 11:07:42 2012 +0100

fdo#46859: adapt string type checks to work with both Python 2 and 3

(regression from a09ce46818fd4d5e08b3af9a478501cd8ef5b4fe)
(cherry picked from commit 4634cbc237239da771e0f6a81f78171ecec726ba)

Signed-off-by: Caolán McNamara caol...@redhat.com

diff --git a/pyuno/source/module/uno.py b/pyuno/source/module/uno.py
index f93ac5e..e82d2fe 100644
--- a/pyuno/source/module/uno.py
+++ b/pyuno/source/module/uno.py
@@ -35,6 +35,12 @@ try:
 except ImportError:
 import builtins as __builtin__
 
+try:
+unicode
+except NameError:
+# Python 3 compatibility
+unicode = str
+
 import socket # since on Windows sal3.dll no longer calls WSAStartup
 
 # all functions and variables starting with a underscore (_) must be 
considered private
@@ -159,9 +165,9 @@ class Bool(object):
Note: This class is deprecated. Use python's True and False directly 
instead
 
 def __new__(cls, value):
-if isinstance(value, str) and value == true:
+if isinstance(value, (str, unicode)) and value == true:
 return True
-if isinstance(value, str) and value == false:
+if isinstance(value, (str, unicode)) and value == false:
 return False
 if value:
 return True
@@ -171,7 +177,7 @@ class Char:
 Represents a UNO char, use an instance of this class to explicitly pass a 
char to UNO
 # @param value pass a Unicode string with length 1
 def __init__(self,value):
-assert isinstance(value, str)
+assert isinstance(value, unicode)
 assert len(value) == 1
 self.value=value
 
@@ -179,7 +185,7 @@ class Char:
 return Char instance %s % (self.value, )
 
 def __eq__(self, that):
-if isinstance(that, str):
+if isinstance(that, (str, unicode)):
 if len(that)  1:
 return False
 return self.value == that[0]
commit 82bf2998cb243f3269e39de8daee56cb6bc04550
Author: David Bolen db3l@gmail.com
Date:   Wed Mar 7 11:13:52 2012 +0100

fdo#46926: fix UNO struct comparison in Python 2

This requires setting a rich comparison flag in Python 2, while Python 3
uses rich comparison by default.
(regression from a09ce46818fd4d5e08b3af9a478501cd8ef5b4fe)
(cherry picked from commit 387389b644b91808fdee74846b2d855382f48ed7)

Signed-off-by: Caolán McNamara caol...@redhat.com

diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index 2bfbe7b..82e29ac 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -641,9 +641,16 @@ static PyObject* PyUNO_cmp( PyObject *self, PyObject 
*that, int op )
 {
 raisePyExceptionWithAny( makeAny( e ) );
 }
-return Py_False;
+return (op == Py_EQ ? Py_False : Py_True);
 }
 
+/* Python 2 has a tp_flags value for rich comparisons.  Python 3 does not (on 
by default) */
+#ifdef Py_TPFLAGS_HAVE_RICHCOMPARE
+#define TP_FLAGS (Py_TPFLAGS_HAVE_RICHCOMPARE)
+#else
+#define TP_FLAGS 0
+#endif
+
 static PyTypeObject PyUNOType =
 {
 PyVarObject_HEAD_INIT( PyType_Type, 0 )
@@ -654,7 +661,7 @@ static PyTypeObject PyUNOType =
 (printfunc) 0,
 (getattrfunc) PyUNO_getattr,
 (setattrfunc) PyUNO_setattr,
-0,
+(cmpfunc) 0,
 (reprfunc) PyUNO_repr,
 0,
 0,
@@ -665,7 +672,7 @@ static PyTypeObject PyUNOType =
 (getattrofunc)0,
 (setattrofunc)0,
 NULL,
-0,
+TP_FLAGS,
 NULL,
 (traverseproc)0,
 (inquiry)0,
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - pyuno/source sw/source

2012-02-20 Thread Michael Meeks
 pyuno/source/module/pyuno_gc.cxx |5 -
 sw/source/filter/ww8/ww8par.cxx  |6 ++
 2 files changed, 6 insertions(+), 5 deletions(-)

New commits:
commit ca6d45fff41bb4765bfc6b3c72e8fad224273ff1
Author: Michael Stahl mst...@redhat.com
Date:   Sat Feb 18 00:06:41 2012 +0100

pyuno: decreaseRefCount: valgrind warning:

Apparently the thread spawned in decreaseRefCount runs and deletes
itself before the m_hThread != 0 from osl::Thread::create is executed;
try a lame workaround for that.

==1877== Invalid read of size 8
==1877==at 0x2A70E546: osl::Thread::create() (in 
pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x2A70E351: pyuno::decreaseRefCount(_is*, _object*) (in 
pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x2A7092B4: pyuno::Adapter::~Adapter() (in 
pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x2A709393: pyuno::Adapter::~Adapter() (in 
pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x5EF2F64: cppu::OWeakObject::release() (weak.cxx:213)
==1877==by 0x2A70DE69:
==1877==  Address 0x1ee30818 is 8 bytes inside a block of size 32 free'd
==1877==at 0x4A0662E: free (vg_replace_malloc.c:366)
==1877==by 0x4C44B62: rtl_freeMemory_SYSTEM(void*) 
(alloc_global.cxx:285)
==1877==by 0x4C44DC7: rtl_freeMemory (alloc_global.cxx:355)
==1877==by 0x2A70E41E: osl::Thread::operator delete(void*) (in 
pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x2A70E6EF: pyuno::GCThread::~GCThread() (in 
pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x2A70E303: pyuno::GCThread::onTerminated() (in 
pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x2A70E671: threadFunc (in pyuno/unxlngx6/lib/libpyuno.so)
==1877==by 0x4C2E242: osl_thread_start_Impl (thread.c:292)
==1877==by 0x3C26607D8F: start_thread (pthread_create.c:309)
==1877==by 0x3C262EF48C: clone (clone.S:115)

Signed-off-by: a very sceptical Michael Meeks michael.me...@suse.com

diff --git a/pyuno/source/module/pyuno_gc.cxx b/pyuno/source/module/pyuno_gc.cxx
index 77eb688..13e6013 100644
--- a/pyuno/source/module/pyuno_gc.cxx
+++ b/pyuno/source/module/pyuno_gc.cxx
@@ -112,7 +112,10 @@ void decreaseRefCount( PyInterpreterState *interpreter, 
PyObject *object )
 // interpreter lock is held or not
 // TODO: Look for a more efficient solution
 osl::Thread *t = new GCThread( interpreter, object );
-t-create();
+// don't call create() because Valgrind complains about invalid read in
+// the rather bizarre GCThread::onTerminated; try a lame workaround:
+t-createSuspended();
+t-resume();
 }
 
 }
commit 7bec16ea0e67d81a1fdf2022cb0985acc51dc691
Author: Michael Stahl mst...@redhat.com
Date:   Wed Feb 8 23:30:21 2012 +0100

sw: ww8: ~SwIndexReg assertion:

Remove pointless SwPosition that triggers the assertion when loading
bugdoc from fdo#39006 from wwExtraneousParas::delete_all_from_doc.

Signed-off-by: Michael Meeks michael.me...@suse.com

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 35def17..1070fdc 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4135,8 +4135,7 @@ void wwExtraneousParas::delete_all_from_doc()
 {
 SwTxtNode *pTxtNode = *aI;
 SwNodeIndex aIdx(*pTxtNode);
-SwPosition aPos(aIdx);
-SwPaM aTest(aPos);
+SwPaM aTest(aIdx);
 m_rDoc.DelFullPara(aTest);
 }
 m_aTxtNodes.clear();
commit dcfd811a57e8ffa5bf1a3f17448d6777ba6ce15b
Author: Michael Stahl mst...@redhat.com
Date:   Tue Feb 14 17:47:28 2012 +0100

sw: ww8: ~SwIndexReg assertion:

Remove pointless SwPosition that triggers the assertion when
loading bugdoc from i#87910 from wwSectionManager::InsertSegments.

Signed-off-by: Michael Meeks michael.me...@suse.com

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 9923768..35def17 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4120,8 +4120,7 @@ void wwSectionManager::InsertSegments()
 if (pTxtNd)
 {
 SwNodeIndex aIdx(*pTxtNd);
-SwPosition aPos(aIdx);
-SwPaM aTest(aPos);
+SwPaM aTest(aIdx);
 mrReader.rDoc.DelFullPara(aTest);
 pTxtNd = 0;
 }
___
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits