unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Sebastian Spaeth <Sebastian@SSpaeth.de>
To: 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: Mon, 02 Jan 2012 16:15:58 +0100	[thread overview]
Message-ID: <87hb0ekudt.fsf@SSpaeth.de> (raw)
In-Reply-To: <1323860305-15802-6-git-send-email-4winter@informatik.uni-hamburg.de>

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

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

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2012-01-02 15:16 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 [this message]
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=87hb0ekudt.fsf@SSpaeth.de \
    --to=sebastian@sspaeth.de \
    --cc=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).