[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - pyuno/source
Caolán McNamara
caolan at kemper.freedesktop.org
Mon Mar 12 06:49:26 PDT 2012
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 <mstahl at 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 <caolanm at 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.net at 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 <caolanm at 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.net at 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 <caolanm at 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,
More information about the Libreoffice-commits
mailing list