[PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

Justus Winter 4winter at informatik.uni-hamburg.de
Wed Dec 14 02:58:23 PST 2011


---
 bindings/python/notmuch/globals.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
index 99e6a10..c52790c 100644
--- a/bindings/python/notmuch/globals.py
+++ b/bindings/python/notmuch/globals.py
@@ -17,6 +17,7 @@ along with notmuch.  If not, see <http://www.gnu.org/licenses/>.
 Copyright 2010 Sebastian Spaeth <Sebastian at SSpaeth.de>'
 """
 
+import sys
 from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
 
 #-----------------------------------------------------------------------------
@@ -200,9 +201,9 @@ def _str(value):
 
     C++ code expects strings to be well formatted and
     unicode strings to have no null bytes."""
-    if not isinstance(value, basestring):
+    if not isinstance(value, basestring if sys.version_info[0] == 2 else str):
         raise TypeError("Expected str or unicode, got %s" % str(type(value)))
-    if isinstance(value, unicode):
+    if sys.version_info[0] == 3 or isinstance(value, unicode):
         return value.encode('UTF-8')
     return value
 
-- 
1.7.7.3



More information about the notmuch mailing list