unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Justus Winter <4winter@informatik.uni-hamburg.de>
To: notmuch@notmuchmail.org
Subject: [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3
Date: Wed, 14 Dec 2011 11:58:23 +0100	[thread overview]
Message-ID: <1323860305-15802-6-git-send-email-4winter@informatik.uni-hamburg.de> (raw)
In-Reply-To: <1323860305-15802-1-git-send-email-4winter@informatik.uni-hamburg.de>

---
 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@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

  parent reply	other threads:[~2011-12-14 10:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14 10:58 [python] RFC: supporting python 2 and 3 with one codebase Justus Winter
2011-12-14 10:58 ` [PATCH 1/7] py3k: The execfile built-in has been removed in python 3 Justus Winter
2011-12-14 10:58 ` [PATCH 2/7] py3k: The ConfigParser module has been renamed to configparser Justus Winter
2011-12-14 10:58 ` [PATCH 3/7] py3k: All strings are unicode strings in py3k Justus Winter
2011-12-14 12:17   ` Tomi Ollila
2011-12-14 12:52     ` Justus Winter
2011-12-14 10:58 ` [PATCH 4/7] py3k: Rename .next() to __next__(), add python2.x compatibility alias Justus Winter
2011-12-14 10:58 ` Justus Winter [this message]
2012-01-02 15:15   ` [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3 Sebastian Spaeth
2012-01-04 18:07     ` Tomi Ollila
2012-01-08 14:04       ` Justus Winter
2012-01-08 14:06         ` [PATCH] " Justus Winter
2011-12-14 10:58 ` [PATCH 6/7] py3k: Add and use a mixin class that implements __str__ Justus Winter
2011-12-14 12:26   ` Tomi Ollila
2011-12-14 12:56     ` Justus Winter
2011-12-14 13:04       ` Justus Winter
2011-12-14 10:58 ` [PATCH 7/7] python: add missing conversions from and to utf-8 Justus Winter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323860305-15802-6-git-send-email-4winter@informatik.uni-hamburg.de \
    --to=4winter@informatik.uni-hamburg.de \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).