unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: Sebastian Spaeth <Sebastian@SSpaeth.de>,
	Justus Winter <4winter@informatik.uni-hamburg.de>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3
Date: Wed, 04 Jan 2012 20:07:11 +0200	[thread overview]
Message-ID: <yf6sjjvxrxs.fsf@taco2.nixu.fi> (raw)
In-Reply-To: <87hb0ekudt.fsf@SSpaeth.de>

On Mon, 02 Jan 2012 16:15:58 +0100, Sebastian Spaeth <Sebastian@SSpaeth.de> wrote:
> Happy new year. Pushed patches 1-4 of this series so far. Looking fine,
> but ugh, the below seems like a rather ugly hack in a function that is
> probably called quite often.
> 
> Isn't there a more pretty variant avoiding these sys.version_info checks
> all over the place?
> 
> > @@ -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

Does the Python3StringMixIn stuff in later patches already handle this
patch -- and making this obsolete ?

Tomi

  reply	other threads:[~2012-01-04 18:07 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 ` [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3 Justus Winter
2012-01-02 15:15   ` Sebastian Spaeth
2012-01-04 18:07     ` Tomi Ollila [this message]
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=yf6sjjvxrxs.fsf@taco2.nixu.fi \
    --to=tomi.ollila@iki.fi \
    --cc=4winter@informatik.uni-hamburg.de \
    --cc=Sebastian@SSpaeth.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).