summaryrefslogtreecommitdiff
path: root/pyuno/source
diff options
context:
space:
mode:
authorDavid Bolen <db3l.net@gmail.com>2012-03-07 11:07:42 +0100
committerMichael Stahl <mstahl@redhat.com>2012-03-07 11:17:13 +0100
commit4634cbc237239da771e0f6a81f78171ecec726ba (patch)
tree481047f359a067b0ffc324d23894a47d44b82f0e /pyuno/source
parent73867da36960adf8b79ff34c7094c63aa5a05940 (diff)
fdo#46859: adapt string type checks to work with both Python 2 and 3
Diffstat (limited to 'pyuno/source')
-rw-r--r--pyuno/source/module/uno.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/pyuno/source/module/uno.py b/pyuno/source/module/uno.py
index f93ac5e13fcc..e82d2fee0cb4 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]