diff options
author | David Bolen <db3l.net@gmail.com> | 2012-03-07 11:07:42 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-03-12 13:48:24 +0000 |
commit | fc290187f08981c734d1f2d3f6649c94e3ac6f99 (patch) | |
tree | b5146f1fecd9f3350838c584214b1b0b6a715037 | |
parent | 82bf2998cb243f3269e39de8daee56cb6bc04550 (diff) |
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@redhat.com>
-rw-r--r-- | pyuno/source/module/uno.py | 14 |
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] |